Getting the day of the week from a timestamp using JavaScript

How do I get the day of the week with a timestamp in JavaScript? I would like to get this from the timestamp I specify, not the current date.

thanks

+6
source share
3 answers
var timestamp = 654524560; // UNIX timestamp in seconds var xx = new Date(); xx.setTime(timestamp*1000); // javascript timestamps are in milliseconds document.write(xx.toUTCString()); document.write(xx.getDay()); // the Day 
+6
source
 var timestamp = 1400000000; var a = new Date(timestamp*1000); var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; var dayOfWeek = days[a.getDay()] 

Now the "day of the week" is in the variable dayOfWeek.

+9
source

Try the following:

 var currentTime = new Date(); var day = currentTime.getDate(); 
-1
source

Source: https://habr.com/ru/post/885719/


All Articles