You need to convert the Unix timestamp to DateTime format,
var localDate = new Date(1585852200000).toLocaleDateString("en-US") console.log(localDate); // only local date var localTime = new Date(1585852200000).toLocaleTimeString("en-US") console.log(localTime) // only local time // local datetime console.log(new Date(1585852200000).toLocaleString());
1585852200000 is epoch date. you can convert it as
var date = new Date(1585852200000)
console.log(new Date(1585852200000));
As an alternative from Shivaji's answer:
When you are passing the date through to JS you could cast it as a string with DateTime.ToString("dd/MM/yyyy")
seen here on MSDN.
This will keep its integrity visually, if it is just for display purposes, otherwise you will need to re-cast appropriately in JS (in which case use Shivaji's answer).
JavaScript Date's object will return the DATE object and it's POSITION that is being assigned in your computer. So, when you are working with a date or datetime types, you can use some of the methods that are provided by the Date
object, such as getDate()
and getDay()
. But, a better solution would be to format the Date
object itself. For example: use the toString()
or toUTCString()
methods.
var d = new Date();
document.getElementById("demo").innerHTML = d.toString();
Reference:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.