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