- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有像 /Date(1370001284000+0200)/
这样的时间戳。我想这是一个 unix 日期,不是吗?我如何将其转换为这样的日期:31.05.2013 13:54:44
我试过了 THIS 1370001284 的转换器,它给出了正确的日期。所以它以秒为单位。
但我仍然得到错误的日期:
var substring = unix_timestamp.replace("/Date(", "");
substring = substring.replace("000+0200)/", "");
var date = new Date();
date.setSeconds(substring);
return date;
最佳答案
Note my use of
t.format
comes from using Moment.js, it is not part of JavaScript's standardDate
prototype.
Unix 时间戳是自 1970-01-01 00:00:00 UTC 以来的秒数。
+0200
的存在意味着数字字符串不是 Unix 时间戳,因为它包含时区调整信息。您需要单独处理。
如果您的时间戳字符串以毫秒为单位,那么您可以使用毫秒构造函数和Moment.js。将日期格式化为字符串:
var t = new Date( 1370001284000 );
var formatted = moment(t).format("dd.mm.yyyy hh:MM:ss");
如果您的时间戳字符串以秒为单位,则使用 setSeconds
:
var t = new Date();
t.setSeconds( 1370001284 );
var formatted = moment(t).format("dd.mm.yyyy hh:MM:ss");
关于javascript - 从 unix 时间戳到日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16978331/
给定一个带有多个 date_time 戳的字符串,我想 提取第一个戳及其前面的文本 候选字符串可以有一个或多个时间戳 后续的 date_time 戳记将被 sep="-" 隔开 后续date_time
是否可以合并从相机拍摄的文本和照片?我想在照片上标记日期和时间,但我在 Google 上找不到任何内容。 最佳答案 使用下面的代码来实现你所需要的。 Bitmap src = Bitm
有没有办法通过 Graph API 戳另一个用户?基于this post ,并使用 Graph Explorer ,我发布到“/USERID/pokes”,我已经授予它(Graph API 应用程序和
我有两个向左浮动的元素。一个是 body 的第一个 child ,另一个是容器的第一个 child ,容器是 body 的第二个 child 。 ...
我是一名优秀的程序员,十分优秀!