JavaScript Date in this format: "Wednesday, March 03, 2010 5:44:15 AM"

I want to show the date on this website "Wednesday, March 03, 2010 05:44:15 PM".

If I use JavaScript, it will take a long code. Is there any other way to do this?

+3
source share
2 answers

You might be interested in the Datejs library .

You can easily try by including a datejs script in your HTML file:

<script type="text/javascript" 
        src="http://datejs.googlecode.com/files/date.js"></script>

Then you can use the method toString()to format the date as needed:

new Date().toString("dddd, MMMM dd, yyyy hh:mm:ss tt");

// returns "Wednesday, March 03, 2010 01:40:18 PM"
+5
source

I think you can format it on the server side.

+1
source

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


All Articles