I develop a application with node.js and mongodb.
I think the question is also available in javascript. How can I convert the date format to the way I want,
like yyyy/mm/dd/hh/mm/ss
?
I develop a application with node.js and mongodb.
I think the question is also available in javascript. How can I convert the date format to the way I want,
like yyyy/mm/dd/hh/mm/ss
?
> var a = new Date()
> a
ISODate("2013-01-01T13:50:36.839Z")
> a.getFullYear() + "/" + (a.getMonth() + 1) + "/" + a.getDate() + "/" + a.getHours() + "/" + a.getMinutes() + "/" + a.getSeconds()
2013/1/1/16/50/36
The code can be improved with string formatting methods. Also, take look at this.
yearMonthDay: { $dateToString: { format: "%Y-%m-%d-%H-%M", date: {$subtract:["$cdt",14400000]}}}