Sharepoint : Changing date format using javascript

I would recommend to use : Moment.js library (link)

Format Dates

moment().format('MMMM Do YYYY, h:mm:ss a'); // December 6th 2018, 11:55:15 am
moment().format('dddd');                    // Thursday
moment().format("MMM Do YY");               // Dec 6th 18
moment().format('YYYY [escaped] YYYY');     // 2018 escaped 2018
moment().format();                          // 2018-12-06T11:55:15+01:00

Relative Time

moment("20111031", "YYYYMMDD").fromNow(); // 7 years ago
moment("20120620", "YYYYMMDD").fromNow(); // 6 years ago
moment().startOf('day').fromNow();        // 12 hours ago
moment().endOf('day').fromNow();          // in 12 hours
moment().startOf('hour').fromNow();       // an hour ago


var myDate = new Date("1/1/1990")
myDate.setMonth(myDate.getMonth() + 1);

myDate.setDate (myDate.getDate() - 1);


// Output: Wed Jan 31 00:00:00 PST 1990
var today = new Date(new Date().setHours(0,0,0,0));


Since 20 years I work on Database Architecture and data migration protocols. I am also a consultant in Web content management solutions. I am an experienced web-developer with over 10 years developing PHP/MySQL, C#, VB.Net applications ranging from simple web sites to extensive web-based business applications. When not writing code, I like to dance salsa and swing and have fun with my little family.

You may also like...