johnwayne77 Posted February 2, 2007 Share Posted February 2, 2007 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 More sharing options...
pikemsu28 Posted February 2, 2007 Share Posted February 2, 2007 check out the date function from php.net http://us2.php.net/manual/en/function.date.php particularly at section: Example 415. date() and mktime()example Link to comment https://forums.phpfreaks.com/topic/36812-solved-display-tomorrow-date/#findComment-175606 Share on other sites More sharing options...
johnwayne77 Posted February 2, 2007 Author Share Posted February 2, 2007 i've tried the mktime() function but it displays just a number (e.g. 14569012) maybe coz if misusage anyone knows how the mktime works in my situation? Link to comment https://forums.phpfreaks.com/topic/36812-solved-display-tomorrow-date/#findComment-175612 Share on other sites More sharing options...
chronister Posted February 2, 2007 Share Posted February 2, 2007 <?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 https://forums.phpfreaks.com/topic/36812-solved-display-tomorrow-date/#findComment-175639 Share on other sites More sharing options...
johnwayne77 Posted February 2, 2007 Author Share Posted February 2, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/36812-solved-display-tomorrow-date/#findComment-175661 Share on other sites More sharing options...
richardw Posted February 2, 2007 Share Posted February 2, 2007 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 https://forums.phpfreaks.com/topic/36812-solved-display-tomorrow-date/#findComment-175670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.