note 86084 modified in function.mktime by danbrown

From: Date: Thu, 02 Oct 2008 15:03:34 +0000
Subject: note 86084 modified in function.mktime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-144978@lists.php.net to get a copy of this message
Don't know about others, but this makes more sense to me: <?php function dateserial($year,$month,$day,$hour,$minute,$timezone = "UTC") { $orgTZ = date_default_timezone_get(); date_default_timezone_set($timezone); $retval = mktime($hour,$minute,0,$month,$day,$year); date_default_timezone_set($orgTZ); return $retval; } ?> The order makes more sense and the timezone defaults to UTC unless otherwise specified. The fact that you have to set the timezone gives you more control and forces you to be aware of it. --was-- Don't know about others, but this makes more sense to me: function dateserial($year,$month,$day,$hour,$minute,$timezone = "UTC") { $orgTZ = date_default_timezone_get(); date_default_timezone_set($timezone); $retval = mktime($hour,$minute,0,$month,$day,$year); date_default_timezone_set($orgTZ); return $retval; } The order makes more sense and the timezone defaults to UTC unless otherwise specified. The fact that you have to set the timezone gives you more control and forces you to be aware of it. http://php.net/manual/en/function.mktime.php

« previous php.notes (#144978) next »