简体   繁体   English

PhantomJS:cygwin返回与windows cmd不同的JS日期

[英]PhantomJS: cygwin returns different JS date than windows cmd

I'm seeing something strange when running PhantomJS through Cygwin versus a windows command prompt. 通过Cygwin运行PhantomJS而不是Windows命令提示符时,我看到一些奇怪的东西。 Specifically, the value of a JavaScript Date object returned is different depending on the terminal you running out of. 具体来说,返回的JavaScript Date对象的值因您用完的终端而异。

I'm using a Win7 64bit machine, with PhantomJS 1.9.7 and Cygwin 1.7.28(0.271/5/3). 我使用的是Win7 64bit机器,配有PhantomJS 1.9.7和Cygwin 1.7.28(0.271 / 5/3)。

Results from CYGWIN: CYGWIN的结果:

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

Results from Win CMD: Win CMD的结果:

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

Any idea why CYGWIN would return "2013-09-30T23:00:00.000Z" and CMD returns "2013-10-01T07:00:00.000Z" ? 知道为什么CYGWIN会返回"2013-09-30T23:00:00.000Z"并且CMD返回"2013-10-01T07:00:00.000Z"

I had the same problem with running phantomjs / poltergeist automated tests under cygwin / babun. 我在cygwin / babun下运行phantomjs / poltergeist自动测试时遇到了同样的问题。

unset TZ

solved the problem, put it in your .zshrc or .bashrc or similar for a permanent fix. 解决了这个问题,将它放在你的.zshrc或.bashrc或类似内容中,以便永久修复。

Credit to: localtime returns GMT for windows programs running on cygwin shells 感谢localtime返回在cygwin shell上运行的Windows程序的GMT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM