note 50735 added to function.mktime

From: Date: Tue, 08 Mar 2005 14:35:15 +0000
Subject: note 50735 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-86106@lists.php.net to get a copy of this message
This is my way to get unix timestamp. <? $serverdate = gmstrftime("%Y-%m-%d %H:%M:%S"); echo $serverdate."<br>"; function extract_date($date){ $arr = explode(" ",$date); $d = $arr[0]; $t = $arr[1]; $arr_d = explode("-",$d); $year = $arr_d[0]; $year = intval($year); $month = $arr_d[1]; $month = intval($month); $day = $arr_d[2]; $day = intval($day); $arr_t = explode(":",$t); $hour = $arr_t[0]; $hour = intval($hour); $minute = $arr_t[1]; $minute = intval($minute); $second = $arr_t[2]; $second = intval($second); return array($hour, $minute, $second, $month, $day, $year); } function unix_timestamp($date) { $a = extract_date($date); $b = mktime($a[0],$a[1],$a[2],$a[3],$a[4],$a[5]); return $b; } /* $a = extract_date($serverdate); echo "<pre>"; print_r($a); echo "</pre>"; */ echo "<br><br><br>"; echo "Unix TimeStamp:<br>"; $b = unix_timestamp($serverdate); echo $b."<br>"; ?> ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50735 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50735&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50735&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50735&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50735&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50735&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50735&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86106) next »