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
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.

Link to comment
Share on other sites

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;

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.