date() function

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
User avatar
xlordt
New php-forum User
New php-forum User
Posts: 34
Joined: Thu Dec 12, 2002 9:00 pm
Location: NJ
Contact:

date() function

Post by xlordt » Mon Jan 20, 2003 4:21 am

im tring to create this script that.. if today is the 20 then echo this.. but if its not the 20 then echo else... but i cant get it ..

Code: Select all

<?php

$today = date("l, j, y");
$start = date("monday, 20, 03");
echo $today;

if($today == $start){
 echo "<Br>YaY the day has come!";
}else{
   echo "<Br>You have to wait till the 20th to access this code";
}


?>


can anyone tell me how do i go by this.. thanx

User avatar
xlordt
New php-forum User
New php-forum User
Posts: 34
Joined: Thu Dec 12, 2002 9:00 pm
Location: NJ
Contact:

Post by xlordt » Tue Jan 21, 2003 7:45 am

err and how do i do that... any hints..

User avatar
xlordt
New php-forum User
New php-forum User
Posts: 34
Joined: Thu Dec 12, 2002 9:00 pm
Location: NJ
Contact:

Post by xlordt » Tue Jan 21, 2003 9:15 am

ahh i c what your saying.. ok thanx.. i will search the manual .. and i think you have to use.. stcmp() to compare the strings.. but anyways.. i will go and check.. thanx

User avatar
WiZARD
Moderator
Moderator
Posts: 1256
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: date() function

Post by WiZARD » Wed Jan 22, 2003 8:48 am

Hi!
If you want what i'm solve youre problemdo next:

Code: Select all

<?php

$today = date("l, j, y");
$start = date("Monday, 20, 03");
echo $today;

if($today == $start){
 echo "<Br>YaY the day has come!";
}else{
   echo "<Br>You have to wait till the 20th to access this code";
}


?>


or this:

Code: Select all

<?php

$today = date("l, j, y");
$start = ("Monday, 20, 03");
echo $today;

if($today == $start){
 echo "<Br>YaY the day has come!";
}else{
   echo "<Br>You have to wait till the 20th to access this code";
}


?>


P.S. you no need about timestamp cause you compare simple string :!: :wink:

Post Reply

Who is online

Users browsing this forum: phpnoob and 1 guest