【问题标题】:Parse date string in RFC 2822 format (as found in HTTP header field `last-modified`)以 RFC 2822 格式解析日期字符串(在 HTTP 标头字段“last-modified”中找到)
【发布时间】:2011-12-27 16:46:07
【问题描述】:

我正在使用 Node.js 。在 HTTP 响应标头中有一个字段 last-modified,其中包含一个字符串,表示根据 RFC 2822 的日期和时间

 'last-modified': 'Tue, 27 Dec 2011 02:12:35 GMT',

如何将其转换为 Javascript Date 对象?

【问题讨论】:

    标签: javascript date node.js


    【解决方案1】:

    JS Date 方法有什么问题?

    new Date( 'Tue, 27 Dec 2011 02:12:35 GMT' )
    

    【讨论】:

    • 你是对的。谢谢。我想要的是一个 Unix 时间戳,我发现 Date.parse(''Tue, 27 Dec 2011 02:12:35 GMT')/1000 可以做到这一点。
    猜你喜欢
    • 1970-01-01
    • 2010-12-28
    • 2011-01-28
    • 2012-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多