Every line of 'javascript date tostring' 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.
131 function to_string_date(date) { 132 var day = date.getDate(), 133 month = date.getMonth()+1, 134 year = date.getFullYear(); 135 136 day < 10 ? day = '0' + day : true; 137 month < 10 ? month = '0' + month : true; 138 139 return month+'/'+day+'/'+year; 140 }
82 function dateToLocaleString(dt, cal) { 83 var wStr = cal.cfg.getProperty("WEEKDAYS_LONG")[dt.getDay()]; 84 var dStr = dt.getDate(); 85 var mStr = cal.cfg.getProperty("MONTHS_LONG")[dt.getMonth()]; 86 var yStr = dt.getFullYear(); 87 return (wStr + ", " + dStr + " " + mStr + " " + yStr); 88 }
9 export function dateToString(date) { 10 const month = pad(date.getMonth() + 1) 11 const day = pad(date.getDate()) 12 const hour = pad(date.getHours()) 13 const minute = pad(date.getMinutes()) 14 const second = pad(date.getSeconds()) 15 return `${date.getFullYear()}/${month}/${day} ${hour}:${minute}:${second}` 16 }
106 export function dateToString(format, inDate) { 107 if (!(inDate instanceof Date)) { 108 inDate = new Date(inDate * 1000); 109 } 110 111 let skip = false; 112 113 return format 114 .split('') 115 .map(c => { 116 if (skip) { 117 skip = false; 118 return c; 119 } 120 if (c === '\\') { 121 skip = true; 122 return ''; 123 } 124 125 return replacements[c] ? replacements[c](inDate) : c; 126 }) 127 .join(''); 128 }
12 toJsDate() { 13 return new Date(this._value.getTime()); // return a clone. 14 }
170 dateToString(date: Date | Moment | string): string { 171 if (date instanceof Date) { 172 return date.toISOString(); 173 } 174 return moment(date).toISOString(); 175 }
200 public toJavaScriptDate(implicitTimezone = undefined): Date { 201 const timezoneToUse = 202 this._timezone || implicitTimezone || DayTimeDuration.fromTimezoneString('Z'); 203 return new Date( 204 Date.UTC( 205 this._years, 206 this._months - 1, 207 this._days, 208 this._hours - timezoneToUse.getHours(), 209 this._minutes - timezoneToUse.getMinutes(), 210 this._seconds + this.secondFraction 211 ) 212 ); 213 }
109 function toDate (string) { 110 return new Date(Date.parse(string)) 111 }
55 public getDateString(): string { 56 return "" + this.day + "." + this.month + "." + this.year + "."; 57 }
77 function stringToDate(strDate) { 78 var dateParts = strDate.split("-"); 79 return new Date(dateParts[0], (dateParts[1] - 1), dateParts[2]); 80 }