我想获得格林威治标准时间的当前时间戳; 任何想法如何做到这一点?
我设法得到gmt格式的字符串问题是我想将此字符串转换为等效的时间戳对象,即同一时间但作为时间戳对象
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzz");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date=new Date();
String s=sdf.format(date);
System.out.println("GMT: "+s);
//need to convert the string to equivalent timestamp object
Run Code Online (Sandbox Code Playgroud) 我在Linux上用C编写一个简单的Web服务器.
我必须添加一个文件的最后修改时间,该文件将被传输到客户端(浏览器),
我分析了一些网站的情况并发现它们都以格式呈现时间:
Fri, 12 Nov 2010 16:02:54 GMT,
我的问题是,我可以简单地将time_t值转换为前一种格式的字符串吗?有这个功能吗?或者格式是不重要的?
如何使用在美国服务器上执行的PERL脚本确定各个国家/地区的当前日期和时间?例如,getDTnow()应确定服务器上的当前日期和时间,并使用它来返回各个国家/地区的日期和时间.
PS:如果只使用内置函数,没有任何外部模块,那将是很好的.
结论:日期数学是[使用脏话这里]复杂,容易出错.IRC上的其他perl专家,小组和网络的其他部分证实了以太一直在建议我 - 使用DateTime.DVK的解决方案也非常适合那些不介意搞乱perl环境的人.(注意:虽然在Windows上,Time :: Piece文档的警告部分说当在Win32上的Threads中设置$ ENV {TZ}时应该小心).
我在varchar数据类型的表中有一个字段,其中包含1800 + 0100的时间,如何在格林尼治标准时间19:00显示它?是否有任何C#方法将时间作为1800 + 0100并转换为19:00?
提前致谢.任何帮助将不胜感激.
发布日期String返回为:Sun,2012年11月18日06:50:02 GMT和我的convertDate方法返回java.text.ParseException:Unparseable date:"Sun,2012年11月18日06:50:02 GMT"(在抵消8).我检查了资源,但找不到像这样的帮助... 使用SimpleDateFormat解析带有GMT时区的字符串到日期
如果你能对它有所了解,真的很感激.这是我的方法.. pubDate这里是Sun,2012年11月18日06:50:02 GMT
public Date convertDate(String pubDate){
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MM yyyy hh:mm:ss Z",Locale.US);
Date newsDate = new GregorianCalendar(0, 0, 0).getTime();
try{
newsDate = sdf.parse(pubDate);
}catch(ParseException e){
Log.d(Tag, "Exception Parsing date" + pubDate);
}
return null;
}
Run Code Online (Sandbox Code Playgroud) 请检查stackoverflow,但无法找到正确答案.我想在网站上输出我的国家尼日利亚的日期.
尼日利亚时区是GMT + 01:00
我有这个
<?php
date_default_timezone_set("WAT");
echo date("M d, Y h:i a")."<p></p>";
//echo time();
?>
Run Code Online (Sandbox Code Playgroud) 我需要在 Ruby 中生成一个 HTTP (GMT) 日期字符串。这是因为我需要使用一个 API。
生成它的简单(开箱即用)方法是什么?
我正在构建一个PHP Web应用程序,需要知道当前的日期/时间.我不能依赖服务器的设置.我可以使用的任何网络服务?我知道通过网络服务访问时间会有一些延迟,但我对一些不精确到最后一毫秒的事情很好.
更新
我需要获得不同时区的两个日期时间之间的小时和分钟差异.
我有MySQL中的日期时间,以及从GMT到MySQL的位置的偏移量.
我尝试过的:
<cfset departure = CreateDateTime(2017,01,27,21,00,00)> <!--- (this time zone is +2) --->
<cfset arrival = CreateDateTime(2017,01,28,06,40,00)> <!--- (this time zone is -5) --->
<cfset depart_timezone = 2>
<cfset arrive_timezone = -5>
<cfset difference = datediff("h",departure,arrival)><!--- get the difference in hours --->
<cfset timezonedif = depart_timezone - arrive_timezone><!--- get the difference between the time zones (answer should be 7)--->
<cfset duration = difference + timezonedif><!--- add the time zone difference to the flight difference --->
<cfoutput>
(Duration: #duration# …Run Code Online (Sandbox Code Playgroud) 我正在写一个python应用程序,它将YML文件转换为我的博客的静态HTML页面(静态站点生成器).我想添加RSS提要.在某个地方,我读到发布日期必须是:
<pubDate>Wed, 05 Jul 2017 18:38:23 GMT</pubDate>
Run Code Online (Sandbox Code Playgroud)
但是我有:
<pubDate>2017-07-05T18:38:23+00:00</pubDate>
Run Code Online (Sandbox Code Playgroud)
datetime来自Python 的API对于这些来说非常麻烦.如何将字符串转换2017-07-05T18:38:23+00:00为GMT?
谢谢你的到来.