Jump to content

[SOLVED] display tomorrow date


johnwayne77

Recommended Posts

i am displaying today's date with the following code:

 

<blockquote>
  <div align="center"><?
  echo date(r);
  ?>
  </div>
</blockquote>

 

the result is something like this:

 

Fri, 02 Feb 2007 20:54:59 +0200

 

Now, I want to display the date of tomorrow, yesterday, the day after tomorrow and so on so it would display like this:

 

Sat, 03 Feb 2007 (without the hour of course)

 

do you have any ideas?

Link to comment
https://forums.phpfreaks.com/topic/36812-solved-display-tomorrow-date/
Share on other sites

<?php

$new_stamp=mktime(0,0,0,date(m), date(d)+1, date(y));

 

echo date("m-d-Y",$new_stamp);

 

// This will print 01-03-2007.

 

$new_stamp=mktime(0,0,0,date(m), date(d)+2, date(y));

 

echo date("m-d-Y",$new_stamp);

 

This will print 01-04-2007.

?>

 

 

 

you can modify the "m-d-y" part to suit your format. Check out the date function help pages for the listing of display formats.

A date funtion that returns the current year if  at least February or no later than November. Otherwise this script returns the current year, in November it will display 2007-2008 and last month, January it would have returned 2006-2007. This way the page always appears current ( a trash pickup schedule). The principals are the same for future and past dates.

 

<?php

$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"),  date("Y"));

$nexttmonth = mktime(0, 0, 0, date("m")+2, date("d"),  date("Y"));

$lookahead = date("m")+2;

$lookback = date("m")-1;

$year0 = date('Y')-1;

$year1 = date('Y') ;

$year2 = date('Y')+1;

$nextyear  = mktime(0, 0, 0, date("m"),  date("d"),  date("Y")+1);

if ($lookahead == "1") {

echo $year1," - ",$year2;

} elseif ( $lookback == "12" ) {

echo $year0," - ",$year1;

} else {

echo  $year1;

}

?>

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.