Reputation: 5941
How do I get the "UTC, PST, EST, etc.." name from this time offset? You can copy/paste this in any PHP file and it will run.
<?php
date_default_timezone_set('UTC');
$time = '2012-01-01T21:15:00+00:00';
echo '<pre>';
echo "<b>Step 1 (Have the date now)</b>\n";
$time = explode('T', $time);
print_r($time);
echo "\n\n<b>Step 2 (Get the offset)</b>\n";
$offset = explode('+', $time[1]);
$time[1] = $offset[0];
print_r($offset);
echo "\n\n";
echo date('l F jS', strtotime($time[0])) . ', at ' . date('g:ia', strtotime($time[1]));
echo "\n\n";
//
// How do I matchup the offset in this list?
// The values are -18000, -7200
//
$b = timezone_abbreviations_list();
print_r($b);
Note: I've also tried using echo date('c', $time);
but perhaps I have something wrong its giving me an error.
Upvotes: 0
Views: 1685
Reputation: 767
In PHP 5.1.0+ echo date('e', $time);
will return the timezone information.
Upvotes: 1