I have an AWS Instance running node v10.15.1
From linux:-
$ date
Thu 14 May 16:12:40 BST 2020
BUT node shows...
$ node
> new Date()
2020-05-14T15:13:37.941Z
Now the actual time is 16:12, So Node is showing GMT, but the System knows it really is BST.
My /etc/sysconfig/clock contains:-
ZONE="Europe/London"
UTC=true
It's possible that a re-start might sort this, but I'm trying to find an alternative, less intrusive solution. - any advice appreciated.
Date() in node always returns GMT time regardless of system time zone, you can convert to locale time :
[ec2-user ~]$ date
Thu May 14 17:38:13 BST 2020
[ec2-user ~]$ node
Welcome to Node.js v14.2.0.
Type ".help" for more information.
> d = new Date()
2020-05-14T16:38:54.746Z
> d.toLocaleTimeString()
'5:38:54 PM'
Related
I am running axe-crawler from the command line using node and getting the following error
*ERROR: Thu Jul 23 2020 11:14:32 GMT+0100 (British Summer Time)
Error encountered in using Selenium Webdriver:
ERROR: Thu Jul 23 2020 11:14:32 GMT+0100 (British Summer Time)
[object Object]*
Not really very descriptive. Can anyone point me in the right direction to either be able to get the proper error or even point out where I might be going wrong?
As there did not seem to be a way of accessing the errors, I ended up using a C#/node hybrid, more from a sensible debugging need. I scraped the site with dotnet HtmlAgilityPack and then ran axe-core through node/javascript to produce the json response.
I'm living in Vancouver, west coast of North America, Canada. The original timezone here is PST (pacific standard time, UTC - 8h), but it's now PDT (pacific daylight time, UTC - 7h) since the daylight saving time has started.
The problem is that Node.js uses the original non-DST time, while Ubuntu returns DST.
In the following, both should be 21:44.
$ echo `date` , `node -e "console.log(new Date().toString())"`
Mon May 25 21:44:57 DST 2020 , Mon May 25 2020 20:44:57 GMT-0800 (GMT-08:00)
Why does this happen? How to let Node.js recognize DST?
I use Noce.js v12.16.3 on Ubuntu 18.04.4 as WSL on Windows 10. (Node.js v12.16.3 for Windows works correctly.) TZ env is not set.
UPDATE I don't want to install external libraries.
A more accurate library would be moment.js. You can set the time to recognize DST like this:
moment(timestamp).tz(timezone).isDST()
Here is an example:
moment(1451624400000).tz('America/New_York').isDST();
You can read more about recognized timestamps and timezones in the documentation on the website that I linked above.
My test shows that node does honor daylight saving time:
$ date; node -e "console.log(new Date().toString())";
Fri Jul 17 23:13:32 EDT 2020
Fri Jul 17 2020 23:13:32 GMT-0400 (Eastern Daylight Time)
$ date --date='Fri Jul 17 2020 23:13:32 GMT-0400'
Fri Jul 17 23:13:32 EDT 2020
$ node -v
v10.21.0
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
I have 3 servers, 2 on AWS and one on Digital Ocean, and the timezone for all is set to CDT. But when I check the current time on all 3 by using the date command via command line, none of them matches.
Server1: Wed Jun 12 23:36:01 CDT 2019
Server2: Wed Jun 12 23:45:51 CDT 2019
Server3: Wed Jun 12 23:38:39 CDT 2019
Could anyone please suggest what needs to be done here? Thanks.
Since you have not explicitly said that you have ntp running on them, you'll need to install that. Once that is installed and set up properly, you should show the same exact time on all of them.
I'm using ubuntu for serving my website and I've used Date.now() a couple of times to get the current date. I live in Beirut (which is around 12:40 PM right now) and Date.now() is logging minus 2 hours (10:40 PM).
I changed the localtime of ubuntu by doing this command:
sudo dpkg-reconfigure tzdata
It's printing this:
Local time is now: Tue Feb 27 12:40:59 EET 2018.
Universal Time is now: Tue Feb 27 10:40:59 UTC 2018.
But it still doesn't work.
Basically, I want Date.now() to target the local time instead of universal one...
Date.now() returns the milliseconds elapsed since the UNIX epoch, and has no concept of timezone whatsoever.
I suspect it's Symantec Endpoint Protection but the evidence I have is inconclusive and support seems to think it's all fine. For instance:
$ date && npm test && date
Thu Aug 24 13:58:37 PDT 2017
> gamma-listener#0.2.0 test C:\work\gamma-listener
> lab -Rv -e development -r console ./test/unit
...
9 tests complete (2 skipped)
Test duration: 267 ms
Assertions count: 24 (verbosity: 2.67)
No global variable leaks detected
Thu Aug 24 13:58:53 PDT 2017
So the tests took <0.5s but the whole thing took 15s. That seems extreme. I'm used to 9 tests running in under 1s total on my Mac. This is bash on Windows. It's not hitting a proxy, this is all local (unit tests).
How can I sort out what is taking so long? Can I prove that SEP is causing the slowdown?
Win 10, bash 4.3.46, Node 6.11.2, npm 3.10.10
I can't upgrade Node for another month or so. Kinda doubt that's the issue.
I've had the same trouble. Try disabling Symantec. For me the command is: "%ProgramFiles(x86)%\Symantec\Symantec Endpoint Protection\smc.exe" -stop .
In Powershell, I like to measure the performance of git status, both before and after that change: Measure-Command { git status }