10 examples of 'iso date format javascript' in JavaScript

Every line of 'iso date format javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
115export function formatIso(date) {
116 return (new Date(`${date.toDateString()} 12:00:00 +0000`)).toISOString().substring(0, 10);
117}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

128function formatISO(date?: Date) {
129 if (!date) { return undefined; }
130
131 return date.getUTCFullYear() +
132 '-' + pad(date.getUTCMonth() + 1) +
133 '-' + pad(date.getUTCDate()) +
134 'T' + pad(date.getUTCHours()) +
135 ':' + pad(date.getUTCMinutes()) +
136 ':' + pad(date.getUTCSeconds());
137
138 function pad(num: number) {
139 if (num < 10) {
140 return '0' + num;
141 }
142 return num;
143 }
144}
28export function formatDateTimeStringISO(dateTimeString) {
29 if (!dateTimeString) {
30 return blankValue;
31 }
32 const parts = new Intl.DateTimeFormat('en', {
33 year: 'numeric',
34 month: '2-digit',
35 day: '2-digit',
36 hour: '2-digit',
37 minute: '2-digit',
38 second: '2-digit',
39 hour12: false,
40 }).formatToParts(new Date(dateTimeString));
41 const keys = {};
42 for (const {type, value} of parts) {
43 keys[type] = value;
44 }
45 return `${keys.year}-${keys.month}-${keys.day} ${keys.hour}:${keys.minute}:${keys.second}`;
46}
9function date (isostring) {
10 return isostring
11}
35function getDateTimeISO() {
36 var date = new Date();
37 return date.toISOString();
38}
106getISOTimestamp(date) {
107 return date.toISOString().split('.')[0] + 'Z';
108}
3export function isoDate(date: Date): string{
4 return date_format("isoDateTime")
5}
39function formatISODate(timestamp) {
40 return new Date(timestamp).toISOString()
41 .split("T")
42 .join(" ")
43 .split(".")[0];
44}
14function toISO(date: string) {
15 return date ? new Date(date).toISOString().slice(0, -5) + 'Z' : null;
16}
7function ISODateString(d)
8{
9 function pad(n){ return n < 10 ? '0' + n : n }
10
11 return d.getUTCFullYear()+'-'
12 + pad(d.getUTCMonth()+1)+'-'
13 + pad(d.getUTCDate())+'T'
14 + pad(d.getUTCHours())+':'
15 + pad(d.getUTCMinutes())+':'
16 + pad(d.getUTCSeconds())+'Z';
17}

Related snippets