javascript - Formatting a date in ISO 8601 to minute resolution -
i need format date\time value iso 8601 down minute resolution.
so in format of:
2007-03-01t13:00z
the native toisostring method on date returns seconds , fractionals:
2015-09-30t09:50:03.014z
how can knock off them parts desired format?
i don't think there's function this, below want using regex:
console.log(new date().toisostring().replace(/:\d+.\d+(\w)$/,'$1'))
date.prototype.toisostringminute = function() { return this.toisostring().replace(/:\d+.\d+(\w)$/,'$1'); } console.log(new date().toisostringminute())
Comments
Post a Comment