note 105954 added to function.date
| From: | Dovid at osu1 dot php dot net | Date: | Tue, 27 Sep 2011 13:24:52 +0000 |
| Subject: | note 105954 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183479@lists.php.net to get a copy of this message | ||
Here is a basic example that shows how to use times and dates with epoch and time zones.
<?PHP
echo "Current EPOCH is: ".time() .".\n";
//Changge the TZ to Los Angeles
date_default_timezone_set('America/Los_Angeles');
echo "As you can see after the TZ change to America/Los_Angeles the EPOCH is the same which is:
".time() .".\n";
//Changge the TZ to Prauge
date_default_timezone_set('Europe/Prague');
echo "As you can see after the TZ change to Europe/Prague the EPOCH is the same which is:
".time() .".\n";
//As per our last TZ change we are on Europe/Prague so if we want to get the epoch for 00:00:00 on
01-01-2012 we do:
echo "The value of 00:00:00 on 01-01-2012 for Europe/Praugue is: ".mktime('00',
'00', '00', '1', '1', '2012').".\n";
//To get the epoch of 00:00:00 for today in Europe/Praugue
echo "The value of 00:00:00 for today in Europe/Praugue is: ".mktime('00',
'00', '00', date("n"), date("j"), date("Y")
).".\n";
// We will now change the time zone to America/Loas_Angeles and do the same all over
//Changge the TZ to Los Angeles
date_default_timezone_set('America/Los_Angeles');
//As per our last TZ change we are on America/Los_Angeles so if we want to get the epoch for
00:00:00 on 01-01-2012 we do:
echo "The value of 00:00:00 on 01-01-2012 for America/Los_Angeles is:
".mktime('00', '00', '00', '1', '1',
'2012').".\n";
//To get the epoch of 00:00:00 for today in America/Los_Angeles
echo "The value of 00:00:00 for today in America/Los_Angeles is: ".mktime('00',
'00', '00', date("n"), date("j"), date("Y")
).".\n";
?>
----
Server IP: 212.199.163.163
Probable Submitter: 213.8.118.62
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/105954
Del: integrated -- https://master.php.net/note/delete/105954/integrated
Del: useless -- https://master.php.net/note/delete/105954/useless
Del: bad code -- https://master.php.net/note/delete/105954/bad+code
Del: spam -- https://master.php.net/note/delete/105954/spam
Del: non-english -- https://master.php.net/note/delete/105954/non-english
Del: in docs -- https://master.php.net/note/delete/105954/in+docs
Del: other reasons-- https://master.php.net/note/delete/105954
Reject -- https://master.php.net/note/reject/105954
Search -- https://master.php.net/manage/user-notes.php