10 examples of 'javascript iso date' in JavaScript

Every line of 'javascript iso date' 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
9function date (isostring) {
10 return isostring
11}
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

35function getDateTimeISO() {
36 var date = new Date();
37 return date.toISOString();
38}
106getISOTimestamp(date) {
107 return date.toISOString().split('.')[0] + 'Z';
108}
115export function formatIso(date) {
116 return (new Date(`${date.toDateString()} 12:00:00 +0000`)).toISOString().substring(0, 10);
117}
3export function isoDate(date: Date): string{
4 return date_format("isoDateTime")
5}
14function toISO(date: string) {
15 return date ? new Date(date).toISOString().slice(0, -5) + 'Z' : null;
16}
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}
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}
20export function toISO (dateString) {
21 try {
22 return new Date(dateString).toISOString()
23 } catch (err) {
24 return null
25 }
26}
67export function date(v: Date, f?: string, lang?: string): string {
68 // TODO: localize again at some point, see https://github.com/gosquared/speed-date
69 return v.toISOString();
70}

Related snippets