Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php GoogleDrive API日期/时间_Php_Google Api_Google Drive Api - Fatal编程技术网

Php GoogleDrive API日期/时间

Php GoogleDrive API日期/时间,php,google-api,google-drive-api,Php,Google Api,Google Drive Api,我对Google Drive API的createdDate/modifiedDate有问题。当我得到数据时,时间显示为:2012-10-26T09:27:09.382Z 有没有人可以指导我如何在“正常”的2012-10-26 09:27:.382Z中安排这样的日期 谢谢:)我不知道正确的方法来处理这个问题,但是看起来这个字符串可以在“t”字符上分解,然后从新aray中生成的两个字符串创建一个新的日期 在T上爆炸日期 $date = explode('T', 2012-10-26T09:27:0

我对Google Drive API的createdDate/modifiedDate有问题。当我得到数据时,时间显示为:2012-10-26T09:27:09.382Z

有没有人可以指导我如何在“正常”的2012-10-26 09:27:.382Z中安排这样的日期

谢谢:)

我不知道正确的方法来处理这个问题,但是看起来这个字符串可以在“t”字符上分解,然后从新aray中生成的两个字符串创建一个新的日期

在T上爆炸日期

$date = explode('T', 2012-10-26T09:27:09.382Z);
$date包含一个由两个片段组成的数组,分别位于T之前和之后

date('D M d, Y', strtotime($date[0]));
第二件是秒弦

date('g:i:s a', strtotime($date[1]))
我不确定这个字符串中的Z是什么,但是如果你不想它返回的话,你可以在这里用str_替换Z

date('g:i:s a', strtotime(str_replace('Z', '', $date[1])));

这些是RFC3339时间戳。这是一个Python示例:

def rfc3339_internet(date):
  d = date.strftime('%Y-%m-%dT%H:%M:%S%z')
  return d[:-2] + ':' + d[-2:]
爪哇语

com.google.api.services.drive.model.File lGoogleFile = lMyDriveHelper.getRootFile();
com.google.api.client.util.DateTime lGoogleCreatedDate = lGoogleFile.getCreatedDate();
java.util.Date lTheNormalJavaDate = new Date(lGoogleCreatedDate.getValue());

Java日期的行为为“正常”;)

这就是我所做的。。。问题是,如果谷歌决定删除T或Z,而我不知道它的日期/时间将再次不正确。。。我想谷歌一定已经考虑过了,并且确实写了一些东西来以正确的方式更改日期/时间!但是谢谢你的回答:)我相信谷歌不会改变这一点,因为这个日期格式是网络标准RFC3339,虽然不是很有用,因为它是Phyton,很容易翻译成PHP^^^干杯!