Closed markarik closed 3 years ago
Use this function
https://medium.com/@nmdaniel/fullstack-lipanampesa-api-web-app-with-nodejs-mongodb-atlas-d0c263e56862
function getTimeStamp() { function parseDate(e) { return e < 10 ? "0" + e : e; } var _date = new Date(); var currentTime = new Date( _date.toLocaleString("en-us", { timeZone: "Africa/Nairobi" }) ); var month = parseDate(currentTime.getMonth() + 1); var date = parseDate(currentTime.getDate()); var hour = parseDate(currentTime.getHours()); var minutes = parseDate(currentTime.getMinutes()); var seconds = parseDate(currentTime.getSeconds()); return ( currentTime.getFullYear() + "" + month + "" + date + "" + hour + "" + minutes + "" + seconds ); }
Use Moment js to format the date.
Use this function
https://medium.com/@nmdaniel/fullstack-lipanampesa-api-web-app-with-nodejs-mongodb-atlas-d0c263e56862
function getTimeStamp() { function parseDate(e) { return e < 10 ? "0" + e : e; } var _date = new Date(); var currentTime = new Date( _date.toLocaleString("en-us", { timeZone: "Africa/Nairobi" }) ); var month = parseDate(currentTime.getMonth() + 1); var date = parseDate(currentTime.getDate()); var hour = parseDate(currentTime.getHours()); var minutes = parseDate(currentTime.getMinutes()); var seconds = parseDate(currentTime.getSeconds()); return ( currentTime.getFullYear() + "" + month + "" + date + "" + hour + "" + minutes + "" + seconds ); }