...

View Full Version : php current day date



o0O0o.o0O0o
02-26-2008, 01:22 AM
hi ,


i want to know how can i use the php function to know that current date
Initially i was using unix time stamp.

what i want is


if (now date is 26 feb)
do this

if(now date is 27 feb)
do thta


with unix time stamp method i had to use


$from = strtotime("26 Feb 2008");
$to = strtotime("27 Feb 2008");

if(now >from and now <to)
do this


so here i had to use two variables from and to to get date of 1 day 26 feb

Is there any function which can do it in one step e,g


if (now = 26 feb)
.....

starting from 1 st second of 26 feb to last second of that day

Inigoesdr
02-26-2008, 04:37 AM
$today = date('j M');

switch($today)
{
case '25 Feb':
echo 'today is the 25th of February';
break;

case '26 Feb':
echo 'today is the 26th of February';
break;

case '27 Feb':
echo 'today is the 27th of February';
break;
}

o0O0o.o0O0o
02-26-2008, 05:21 AM
thanks dude
i want to compare the next seven days in advance how can i do that e,g


$next = $today + $i

where $i is variable for next 7 days

then i have to copmare its 26 or 27 or 28 feb

Inigoesdr
02-26-2008, 11:18 AM
Not sure what you're asking, but to get the date of the next day you would use something like this:

$next = date('j M', strtotime('+1 day'));

o0O0o.o0O0o
02-26-2008, 10:41 PM
can i use



$next = date('j M', strtotime('+".$i." day'));

Andrew Johnson
02-26-2008, 10:46 PM
can i use



$next = date('j M', strtotime('+".$i." day'));

No but you can use:



$next = date('j M', strtotime("+".$i." day"));

Inigoesdr
02-26-2008, 11:01 PM
No but you can use:



$next = date('j M', strtotime("+".$i." day"));
Or:

$next = date('j M', strtotime('+' . $i . ' day'));
// or
$next = date('j M', strtotime("+$i day"));
Edit: I guess I should point out that this would be a little slower(roughly 0.0004 seconds) than just adding 86400(the number of seconds in a day) to time() (http://php.net/time); or multiplying the number of days by 86400, and then adding it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum