note 50736 added to function.mktime

From: Date: Tue, 08 Mar 2005 15:08:52 +0000
Subject: note 50736 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-86107@lists.php.net to get a copy of this message
How to get the date of next day(s) ? Please take a look my working code: <? function add_zero($a){ $b = $a; if(strlen($a) == 1){ $b = "0".$a; } return $b; } function day_th($gmt, $no=30){ // default $no = 30 later // get GMT datetime as standard for 'now()' // $gmt = gmstrftime("%Y-%m-%d %H:%M:%S"); $d = explode(" ",$gmt); $date = $d[0]; $time = $d[1]; $date_x = explode("-",$date); $year = $date_x[0]; $month = $date_x[1]; $day = $date_x[2]; $time_x = explode(":",$time); $hour = $time_x[0]; $minute = $time_x[1]; $second = $time_x[2]; // create UNIX TIMESTAMP of the GMT above $t = mktime($hour, $minute, $second, $month, $day, $year); // 1 h = 3600 sec // 1 d = 24 h // 1 d = 86400 sec // 30 d = 2592000 sec $unix_stamp = 86400 * $no; $res = getdate($t + $unix_stamp); $ris = array_values($res); list($seconds,$minutes,$hours,$mday,$wday,$mon,$year, $yday,$weekday,$month,$unix) = $ris; $mon = add_zero($mon); $mday = add_zero($mday); $seconds = add_zero($seconds); $minutes = add_zero($minutes); $hours = add_zero($hours); $day_th = $year."-".$mon."-".$mday." ".$hours.":".$minutes.":".$seconds; return $day_th; } // $gmt = gmstrftime("%Y-%m-%d %H:%M:%S"); $gmt = "2005-02-28 00:00:01"; $nextdate = day_th($gmt, $no=1); echo $gmt."<br>".$nextdate."<br>"; ?> ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50736 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50736&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50736&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50736&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50736&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50736&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50736&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86107) next »