note 105954 deleted from function.date by tularis

From: Date: Sun, 12 Feb 2012 11:22:09 +0000
Subject: note 105954 deleted from function.date by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-186076@lists.php.net to get a copy of this message
Note Submitter: Dovid ---- 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"; ?>

« previous php.notes (#186076) next »