note 50736 deleted from function.mktime by derick

From: Date: Sun, 24 Sep 2006 12:01:44 +0000
Subject: note 50736 deleted from function.mktime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117518@lists.php.net to get a copy of this message
Note Submitter: maxnamara at yahoo dot com ---- 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>"; ?>

« previous php.notes (#117518) next »