简体   繁体   English

时间戳YYYY-MM-DDTHH:MM:SS + 00:00

[英]Timestamp YYYY-MM-DDTHH:MM:SS+00:00

How do I get the "UTC, PST, EST, etc.." name from this time offset? 如何从该时间偏移中获取“ UTC,PST,EST等。”名称? You can copy/paste this in any PHP file and it will run. 您可以将其复制/粘贴到任何PHP文件中,然后它将运行。

<?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); 注意:我也尝试过使用echo date('c', $time); but perhaps I have something wrong its giving me an error. 但也许我出了点问题,这给了我一个错误。

In PHP 5.1.0+ echo date('e', $time); 在PHP 5.1.0+中, echo date('e', $time); will return the timezone information. 将返回时区信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM