var date = new Date();

alert( date.getFullYear() + ("0" + (date.getMonth() + 1)).slice(-2) + ("0" + date.getDate()).slice(-2) + ("0" + date.getHours() ).slice(-2) + ("0" + date.getMinutes()).slice(-2) + ("0" + date.getSeconds()).slice(-2) );

edit

function pad2(n) { return n < 10 ? '0' + n : n }

var date = new Date();
    
alert( date.getFullYear().toString() + pad2(date.getMonth() + 1) + pad2( date.getDate()) + pad2( date.getHours() ) + pad2( date.getMinutes() ) + pad2( date.getSeconds() ) );
Answer from gurvinder372 on Stack Overflow
🌐
JSFiddle
jsfiddle.net › felipekm › MYpQ9
YYYYMMDDHHMMSS Date Format - JSFiddle - Code Playground
For now it's a BYOK implmentation which means you need to provide your own API Key − you can get it for free.
🌐
Mirth Community
forums.mirthproject.io › home › mirth connect › support
Getting the current Datetime in javascript - Mirth Community
I mean you can get it very easy like this: ... var d = new Date(); logger.info(d.toString()); but the result will look like this: Mon Feb 07 2011 09:01:17 GMT+0100 (CET) So I wrote a code template that gives a HL7Compliant DateTime. I thought lets share it. ... //Gets the current Date Time ...
🌐
Sling Academy
slingacademy.com › article › javascript-get-and-format-current-date-time
JavaScript: Get current date time in yyyy/MM/dd HH:mm:ss format - Sling Academy
This concise article shows you how to get the current date and time in Javascript in yyyy/MM/dd HH:mm:ss format. We’ll write code from scratch without using any third-party libraries. In the example below, we will create a new...
🌐
GitHub
gist.github.com › Ivlyth › c4921735812dd2c0217a
format javascript date to format "YYYY-mm-dd HH:MM:SS" · GitHub
const getUTCTimestamp = ()=> { const d = new Date().toISOString().split('T') const date = d[0]; const time = d[1].split('.')[0]; return `${date} ${time}` }
🌐
Medium
trymysolution.medium.com › javascript-date-as-in-yyyy-mm-dd-hh-mm-ss-format-or-mm-dd-yyyy-hh-mm-ss-a0c96e8fa888
JavaScript Date as in YYYY-MM-DD hh:mm:ss Format or MM/DD/YYYY hh:mm:ss | by Yogesh D V | Medium
April 11, 2023 - // 👇️ 2023-04-11 16:21:23 (yyyy-mm-dd hh:mm:ss) //console.log(dateInYyyyMmDdHhMmSs(new Date())); // 👇️️ 2025-05-04 05:24:07 (yyyy-mm-dd hh:mm:ss) // console.log(dateInYyyyMmDdHhMmSs(new Date('May 04, 2025 05:24:07'))); // Date divider ...
🌐
GeeksforGeeks
geeksforgeeks.org › node.js › how-to-format-the-current-date-in-mm-dd-yyyy-hhmmss-format-using-node-js
How to format the current date in MM/DD/YYYY HH:MM:SS format using Node? - GeeksforGeeks
July 23, 2025 - const date = new Date(); // Function to convert // single digit input // to two digits const formatData = (input) => { if (input > 9) { return input; } else return `0${input}`; }; // Function to convert // 24 Hour to 12 Hour clock const formatHour = (input) => { if (input > 12) { return input - 12; } return input; }; // Data about date const format = { dd: formatData(date.getDate()), mm: formatData(date.getMonth() + 1), yyyy: date.getFullYear(), HH: formatData(date.getHours()), hh: formatData(formatHour(date.getHours())), MM: formatData(date.getMinutes()), SS: formatData(date.getSeconds()), };
Find elsewhere
🌐
Zuga
zuga.net › articles › javascript-date-the-tostring-methods
Zuga.net | Javascript - Date() - the toString() methods
The Javascript Date type · doesn't support custom format strings like "yyyyMMddHHmmss". But it does provide a number of methods that return the date as a string in a specific format. The toLocaleString() methods additionally accept a · locale plus · options that provides a considerable degree of customization.
🌐
W3docs
w3docs.com › javascript
How to Format a JavaScript Date
function addLeadingZeros(n) { if (n <= 9) { return "0" + n; } return n } let currentDatetime = new Date() console.log(currentDatetime.toString()); let formattedDate = currentDatetime.getFullYear() + "-" + addLeadingZeros(currentDatetime.getMonth() + 1) + "-" + addLeadingZeros(currentDatetime.getDate()) + " " + addLeadingZeros(currentDatetime.getHours()) + ":" + addLeadingZeros(currentDatetime.getMinutes()) + ":" + addLeadingZeros(currentDatetime.getSeconds()) console.log(formattedDate); Run > Reset · The Date object is used for representing date and time in JavaScript. It includes both of them. As a rule, the months start from zero and end with 11. The weekdays are also counted starting from zero. In JavaScript, the dates might be subtracted and give their difference in milliseconds, as a Date is transformed into timestamp when converted to a number.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › now
Date.now() - JavaScript | MDN
You can use Date.now() to get the current time in milliseconds, then subtract a previous time to find out how much time elapsed between the two calls.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Date and time
// current date let date = new Date(); // the hour in your current time zone alert( date.getHours() ); // the hour in UTC+0 time zone (London time without daylight savings) alert( date.getUTCHours() ); Besides the given methods, there are two special ones that do not have a UTC-variant: ... Returns the timestamp for the date – a number of milliseconds passed from the January 1st of 1970 UTC+0.
🌐
CoreUI
coreui.io › answers › how-to-get-current-timestamp-in-javascript
How to get current timestamp in JavaScript · CoreUI
September 30, 2025 - Use Date.now() to get the current timestamp in JavaScript - the fastest and most reliable method for milliseconds since Unix epoch.
🌐
InterSystems
community.intersystems.com › post › how-get-current-date-and-time-yyyymmddhhmmss-format
How to get current date and time in YYYYMMDDHHMMSS format ? | InterSystems DC
I would like to get current date and time in this format : YYYYMMDDHHMMSS (eg: 20220126155704) Simplest way to do that I found so far is this : $translate($zdatetime($horolog,8,1), " :", "") It works, but it's not that great (I would like to avoid
🌐
Toptal
toptal.com › software › definitive-guide-to-datetime-manipulation
How to get the Timestamp And Date in Javascript: JS DateTime | ...
December 2, 2020 - If you instead want to get the current timestamp in JavaScript, you can create a new Date object and use the getTime() method.
🌐
ui.dev
ui.dev › get-current-timestamp-javascript
How to get the current timestamp in JavaScript
The UNIX timestamp is defined as the number of seconds since January 1, 1970 UTC. In JavaScript, in order to get the current timestamp, you can use Date.now().
🌐
UiPath Community
forum.uipath.com › learning hub
How to create date format YYYYMMDDHHMMSS - Learning Hub - UiPath Community Forum
June 30, 2020 - Hi Guys, I want to save my file this format Filenanme +“YYYYMMDDHHMMSS”+“.pdf”, But when i try this it was not working. Thank you in advance.