Jump to content

get the date after the given date -- please check this out


louis_coetzee

Recommended Posts

Hi people!

 

I would like to get after the one I give my website.

 

$date = '19012009';

 

newdate must be a day after $date or before $date

//must be like the one's below, just need the math.

$date_before = '18012009';

$date_after = '20012009';

 

Please help, and thanks.

I had my fair share of trouble with the php date stuff. Try this - it might help you in the right direction:



//get the current time, or whatever time you're workign with as timestamp
$date = time();

//Get tomorrow's date
$day_after = strtotime("tomorrow",$date);
//get yesterday's date
$day_previous = strtotime("yesterday",$date);

//then use strftime to format the date as you want it.
$day_after_formatted = strftime("%Y-%m-%d", $day_after);
$day_previous_formatted = strftime("%Y-%m-%d", $day_previous);

I had my fair share of trouble with the php date stuff. Try this - it might help you in the right direction:



//get the current time, or whatever time you're workign with as timestamp
$date = time();

//Get tomorrow's date
$day_after = strtotime("tomorrow",$date);
//get yesterday's date
$day_previous = strtotime("yesterday",$date);

//then use strftime to format the date as you want it.
$day_after_formatted = strftime("%Y-%m-%d", $day_after);
$day_previous_formatted = strftime("%Y-%m-%d", $day_previous);

 

Thanks a lot, this looks like what I was looking for.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.