【问题标题】:PhantomJS: cygwin returns different JS date than windows cmdPhantomJS:cygwin 返回与 windows cmd 不同的 JS 日期
【发布时间】:2014-05-14 23:25:50
【问题描述】:

在通过 Cygwin 与 Windows 命令提示符运行 PhantomJS 时,我看到一些奇怪的东西。具体来说,返回的 JavaScript Date 对象的值会因您用完的终端而异。

我使用的是 Win7 64 位机器,带有 PhantomJS 1.9.7 和 Cygwin 1.7.28(0.271/5/3)。

CYGWIN 的结果:

/cygdrive/c
$ phantomjs
phantomjs> var d = new Date("2013/10/01")
undefined
phantomjs> d
"2013-09-30T23:00:00.000Z"

Win CMD 的结果:

C:\> phantomjs
phantomjs> var d = new Date("2013/10/01")
undefined
phantomjs> d
"2013-10-01T07:00:00.000Z"

知道为什么 CYGWIN 会返回 "2013-09-30T23:00:00.000Z" 而 CMD 会返回 "2013-10-01T07:00:00.000Z" 吗?

【问题讨论】:

  • 我有同样的“问题”。在 Win7 32 位上,在 phantomjs 中选择了不同的时区(按 1 小时)。我尝试在cygwin环境下用export TZ=$(tzset)设置,但是没有任何效果。

标签: javascript windows cmd cygwin phantomjs


【解决方案1】:

我在 cygwin / babun 下运行 phantomjs / poltergeist 自动化测试时遇到了同样的问题。

unset TZ

解决了问题,将其放入您的 .zshrc 或 .bashrc 或类似文件中以进行永久修复。

归功于:localtime returns GMT for windows programs running on cygwin shells

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-19
    • 2013-05-14
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多