Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

date.toUTCString() it's not a function [closed]

Hello when i try to convert my date to format UTC it throwing TypeError: date.toUTCString it's not a function any suggestions?

Code

like image 719
andy94 Avatar asked Mar 27 '26 21:03

andy94


1 Answers

As DontVoteMeDown said: Date.now() does not return a date object, instead Date.now() returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.

To get the current timestamp as a Date object

var date = new Date( Date.now() );

Or more simply (but less readable)

var date = new Date(); 
like image 115
Noah Rose Ledesma Avatar answered Mar 31 '26 07:03

Noah Rose Ledesma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!