How to format a UTC date as a `YYYY-MM-DD hh:mm:ss` string using NodeJS?
If you’re using Node.js, you’re sure to have EcmaScript 5, and so Date has a toISOString method. You’re asking for a slight modification of ISO8601: So just cut a few things out, and you’re set: Or, in one line: new Date().toISOString().replace(/T/, ‘ ‘).replace(/\..+/, ”) ISO8601 is necessarily UTC (also indicated by the trailing Z on … Read more