I need to custom format dates. In ruby, I would use strftime, or string formatted time, to accomplish this.
now = Time.new
now.strftime '%a, %d of %b' #=> "Sat, 27 of Jun"
moment().format('dd, d of MMMM')
However, if you do not want to use a library you have access to the following native Date properties:
var now = new Date(); document.write(now.toUTCString() + "<br>") document.write(now.toTimeString() + "<br>")
Date Object some properties
toDateString() Converts the date portion of a Date object into a readable string toGMTString() Deprecated. Use the toUTCString() method instead toISOString() Returns the date as a string, using the ISO standard toJSON() Returns the date as a string, formatted as a JSON date toLocaleDateString() Returns the date portion of a Date object as a string, using locale conventions toLocaleTimeString() Returns the time portion of a Date object as a string, using locale conventions toLocaleString() Converts a Date object to a string, using locale conventions toString() Converts a Date object to a string toTimeString() Converts the time portion of a Date object to a string toUTCString() Converts a Date object to a string, according to universal time