如何将datetime字符串转换为UTC? [英] How to convert a datetime string to UTC?

查看:127
本文介绍了如何将datetime字符串转换为UTC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何转换datetime字符串,如下所示: 2012-09-03 22:00 US根据UTC时区?

How can i convert a datetime string like this: 2012-09-03 22:00 US Estern to UTC timezone?

推荐答案

您应该查看 DateTime 对象及其相关功能在文档中。

You should look at the DateTime object and its related functions in the documentation.

如果您的输入日期已经在一个字符串格式, DateTime :: createFromFormat() 将帮助您创建对象可以使用的时代类型的整数日期。之后,它只是 getTimezone() setTimezone()

If your input date is already in a string format, DateTime::createFromFormat() will help you create an epoch-type integer date the object can work with. After that, it's just getTimezone() and setTimezone().

这篇关于如何将datetime字符串转换为UTC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆