10 examples of 'javascript date string format yyyy-mm-dd' in JavaScript

Every line of 'javascript date string format yyyy-mm-dd' 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
11format (fmt = 'yyyy-MM-dd HH:mm:ss') {
12 const obj = {
13 'y+': this.date.getFullYear(),
14 'M{2}': this._paddingZero(this.date.getMonth() + 1),
15 'd{2}': this._paddingZero(this.date.getDate()),
16 'H{2}': this._paddingZero(this.date.getHours()),
17 'h{2}': this._paddingZero(this.date.getHours() % 12),
18 'm{2}': this._paddingZero(this.date.getMinutes()),
19 's{2}': this._paddingZero(this.date.getSeconds()),
20 'M': this.date.getMonth() + 1,
21 'd': this.date.getDate(),
22 'H': this.date.getHours(),
23 'h': this.date.getHours() % 12,
24 'm': this.date.getMinutes(),
25 's': this.date.getSeconds(),
26 'W': this.date.getDay()
27 }
28 for (let [key, ] of Object.entries(obj)) {
29 const regexp = new RegExp(`(${key})([^a-zA-Z])?`)
30 if (regexp.test(fmt)) {
31 fmt = fmt.replace(RegExp.$1, obj[key])
32 }
33 }
34 return fmt
35}
8static formatDateYYYYMMDD(date) {
9 return DateFormatter.format(date, "yyyy-MM-dd");
10}
486formatDate(d) {
487 const calendar = this;
488 const date = new Date(d);
489 const year = date.getFullYear();
490 const month = date.getMonth();
491 const month1 = month + 1;
492 const day = date.getDate();
493 const weekDay = date.getDay();
494 const { monthNames, monthNamesShort, dayNames, dayNamesShort } = calendar;
495 const { dateFormat, locale } = calendar.params;
496 if (typeof dateFormat === 'string') {
497 return dateFormat
498 .replace(/yyyy/g, year)
499 .replace(/yy/g, String(year).substring(2))
500 .replace(/mm/g, month1 < 10 ? `0${month1}` : month1)
501 .replace(/m(\W+)/g, `${month1}$1`)
502 .replace(/MM/g, monthNames[month])
503 .replace(/M(\W+)/g, `${monthNamesShort[month]}$1`)
504 .replace(/dd/g, day < 10 ? `0${day}` : day)
505 .replace(/d(\W+)/g, `${day}$1`)
506 .replace(/DD/g, dayNames[weekDay])
507 .replace(/D(\W+)/g, `${dayNamesShort[weekDay]}$1`);
508 }
509 if (typeof dateFormat === 'function') {
510 return dateFormat(date);
511 }
512 // Intl Object
513 const formatter = new Intl.DateTimeFormat(locale, dateFormat);
514 return formatter.format(date);
515}
180export function dateFormat(timestamp, format = 'yyyy-MM-dd hh:mm:ss') {
181 timestamp = timestamp.length === 13 ? timestamp : timestamp * 1000
182 let date = new Date(timestamp)
183 let args = {
184 'M+': date.getMonth() + 1,
185 'd+': date.getDate(),
186 'h+': date.getHours(),
187 'm+': date.getMinutes(),
188 's+': date.getSeconds()
189 }
190 if (/(y+)/.test(format)) {
191 format = format.replace(
192 RegExp.$1,
193 (date.getFullYear() + '').substr(4 - RegExp.$1.length)
194 )
195 }
196 for (var i in args) {
197 let n = args[i]
198 if (new RegExp('(' + i + ')').test(format)) {
199 format = format.replace(
200 RegExp.$1,
201 RegExp.$1.length === 1 ? n : ('00' + n).substr(('' + n).length)
202 )
203 }
204 }
205 return format
206}
131function 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}
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}
37function getDate(strDate) {
38 /* istanbul ignore next */
39 return moment(strDate).format('YYYY-MM-DD')
40}
118function formatDateForPicker(date) {
119 var h = date.getHours();
120 var m = date.getMinutes();
121
122 function dd(n) { return (n < 10) ? '0' + n : n; }
123 return date.getFullYear() + "-" + dd(date.getMonth() + 1) + "-" + dd(date.getDate()) + "T" + dd(h) + ":" + dd(m);
124} Registro Remoto <ul><li><span>Habilitar</span><span></span></li><li><span>Intervalo de registro:</span><span> segundos </span></li><li><span>Tipo de Serviço:</span><span></span></li></ul><div><div><ul><li><span>Stream URL:</span><span></span></li><li><span> Beer: </span><span></span></li><li><span> Gravity Unit </span><span><span>SG(1.x)</span><span>Plato(°P)</span></span></li></ul></div><div><ul><li><span>Write API Key:</span><span></span></li><li><span>Fields:</span><span><span>Field 1:</span><span>Field 2:</span><span>Field 3:</span><br /><span>Field 4:</span><span>Field 5:</span><span>Field 6:</span><br /><span>Field 7:</span><span>Field 8:</span></span></li></ul></div><div><ul><li><span>ID:</span><span></span></li><li><span>Device Label:</span><span></span></li></ul></div><div><ul><li><span>Account:</span><span></span></li><li><span>Token:</span><span></span></li><li><span>Device:</span><span></span></li></ul></div><div><ul><li><span>Método:</span><span>Get Post Put</span></li><li><span>URL:</span><span></span></li><li><span>DataType:</span> <span></span></li><li><span></span> <span><u>Especificadores de formato...</u></span></li><li><span>Formato:</span><span></span></li><li><span></span> <span>Caracteres:<span></span></span></li></ul></div></div><br />Atualizar Registro Local <div><div><span>Nome do novo registro:</span> Iniciar registro<div><strong> Opções:</strong><br /> Calibrar iSpindel <br /> Inclinação na água: <span> Densidade medida: , ou água @ ° calibrado °</span></div></div><div><strong></strong> desde <strong></strong> Parar registro</div></div><div> Memória Livre: <span>0</span> Bytes, Memória Utilizada: <span>0</span> Bytes, Memória Total: <span>0</span> Bytes</div><table><tr><th> Nome do novo registro: </th><th> Data </th><th> Ação </th></tr><tr><td></td><td></td><td>DownloadApagar</td></tr></table><div><table><tr><th>%b</th><td> Temp. Cerv.: </td></tr><tr><th>%B</th><td> SP Cerv.: </td></tr><tr><th>%f</th><td> Temp. Refrig.: </td></tr><tr><th>%F</th><td> SP Refrig.: </td></tr><tr><th>%r</th><td> Temp. Ambiente: </td></tr><tr><th>%g</th><td> Densidade </td></tr><tr><th>%p</th><td> Plato </td></tr><tr><th>%a</th><td> Temp. iSpindel </td></tr><tr><th>%v</th><td> Voltagem iSpindel </td></tr><tr><th>%t</th><td> Inclinação </td></tr><tr><th>%u</th><td> Registro de data/hora da última atualização de densidade </td></tr><tr><th>%U</th><td> Temperature in C or F </td></tr><tr><th>%m</th><td> mode in integer </td></tr><tr><th>%M</th><td> mode in character </td></tr><tr><th>%P</th><td> Pressure in PSI </td></tr></table></div>
118function formatDateForPicker(date) {
119 var h = date.getHours();
120 var m = date.getMinutes();
121
122 function dd(n) { return (n &lt; 10) ? '0' + n : n; }
123 return date.getFullYear() + "-" + dd(date.getMonth() + 1) + "-" + dd(date.getDate()) + "T" + dd(h) + ":" + dd(m);
124}<header><h1><span>BrewPiLess</span> <span></span></h1><div><div> <span></span> <span></span> <span></span><ul><li><a href="/index.htm"> graph </a></li><li><a href="/control.htm"> control </a></li><li><a href="/logging.htm"> logs </a></li><li><a href="/setup.htm"> setup </a></li><li><a href="/config.htm"> config </a></li><li><a href="/gravity.htm"> gravity </a></li><li><a href="/pressure.htm"> Pressure </a></li></ul></div></div></header><div><div><div><h5> BrewPiLess Configuration </h5><div><h6> LCD auto off </h6></div><div><h6> Title </h6></div><div><h6> Host/Network Name </h6></div><div><h6> HTTP Port </h6></div><div><h6> User Name </h6></div><div><h6> Password </h6></div><div><h6> Always ask for password </h6></div><div><h6> Network Mode </h6></div><div><h6> Network </h6>...</div><div><h6> IP </h6><span></span></div><div></div></div><div><h5> MQTT Remote Control </h5><div><h6> Enabled: </h6></div><div><h6> MQTT Server: </h6></div><div><h6> MQTT Port: </h6></div><div><h6> Username: </h6></div><div><h6> Password: </h6></div><div><h6> Path for mode: </h6></div><div><h6> Path for setting temperature: </h6></div><div><h6> Path for capping control: </h6></div><div><h6> Path for PTC temperature: </h6></div><div></div></div></div></div><div><div><div> Network Selection </div><div><div><a href="#">N</a> <span></span></div></div><div><a href="#"> Scan </a></div><br /><br /><br /><br /><br /><br /><br /><br />Save Change Cancel</div></div><footer><span>BrewPiLess by <a href="https://github.com/vitotai/">vitotai</a></span> <span><a href="https://github.com/vitotai/BrewPiLess/">project on GitHub</a></span></footer><div><div> Congfiuration saved. Wait for restart... (note: if the hostname is changed, the page won't be reloaded.) </div></div>
118function formatDateForPicker(date) {
119 var h = date.getHours();
120 var m = date.getMinutes();
121
122 function dd(n) { return (n &lt; 10) ? '0' + n : n; }
123 return date.getFullYear() + "-" + dd(date.getMonth() + 1) + "-" + dd(date.getDate()) + "T" + dd(h) + ":" + dd(m);
124}<header><h1><span>BrewPiLess</span> <span></span></h1><div><div> <span></span> <span></span> <span></span><ul><li><a href="/index.htm"> 狀態 </a></li><li><a href="/control.htm"> 控制 </a></li><li><a href="/logging.htm"> 記錄 </a></li><li><a href="/setup.htm"> 設定 </a></li><li><a href="/config.htm"> 系統 </a></li><li><a href="/gravity.htm"> 比重 </a></li><li><a href="/pressure.htm"> 壓力 </a></li></ul></div></div></header><div><div><h4> BrewPiless記錄設定 </h4><div><div><h5> 雲端記錄 </h5><div></div></div><div><h6> 記錄時間間隔: </h6></div><div><h6> Service Type: </h6><div></div></div><div><div><div><h6> Stream URL: </h6></div><div><h6> Beer: </h6></div><div><h6> Gravity Unit </h6><div>SG(1.x)</div><div>Plato(°P)</div></div></div><div><div><h6> Write API Key: </h6></div><div><h6> Fields: </h6><div><span>Field 1:</span><span>Field 2:</span><span>Field 3:</span><br /><span>Field 4:</span><span>Field 5:</span><span>Field 6:</span><br /><span>Field 7:</span><span>Field 8:</span></div></div></div><div><div><h6> ID: </h6></div><div><h6> Device Label: </h6></div></div><div><div><h6> Account: </h6></div><div><h6> Token: </h6></div><div><h6> Device: </h6></div></div><div><div><h6> Method: </h6><div>GET</div><div>POST</div><div>PUT</div></div><div><h6> URL: </h6></div><div><h6>Data Type:</h6></div><p>JSON:"application/json", Form Type:"application/x-www-form-urlencoded"</p><div><h6> 格式: </h6><div><div><span><u>符號...</u></span><span> 字元數: <span>0/256</span></span></div></div></div></div></div><div>更新變更</div></div><div><h5> 本地記錄 </h5><div><div><h6> 新記錄檔名: </h6> 開始記錄</div><div><h6> 選項: </h6></div><div><h6> 校正iSpindel </h6></div><div><h6> 在水中的Tilt值 </h6></div><div><h6> 比重計讀數: </h6></div><div><h6> , 或是水溫 @ </h6>° 比重計修正溫度 °</div></div><div> 記錄中 <strong></strong> 記錄開始於 <strong></strong> 停止記錄</div><div> 可使用空間: <span>0</span> Bytes, 已使用空間: <span>0</span> Bytes, 全部空間: <span>0</span> Bytes</div><h5> 記錄檔案 </h5><table><tr><th> 記錄 </th><th> 日期 </th><th> 動作 </th></tr><tr><td></td><td></td><td>下載 刪除</td></tr></table></div></div></div><footer><span>BrewPiLess by <a href="https://github.com/vitotai/">vitotai</a></span> <span><a href="https://github.com/vitotai/BrewPiLess/">project on GitHub</a></span></footer><div><table><tr><th>%b</th><td> 啤酒溫度 </td></tr><tr><th>%B</th><td> 啤酒設定溫度 </td></tr><tr><th>%f</th><td> 冰箱溫度 </td></tr><tr><th>%F</th><td> 冰箱設定溫度 </td></tr><tr><th>%r</th><td> 室溫 </td></tr><tr><th>%g</th><td> 比重 </td></tr><tr><th>%p</th><td> Plato </td></tr><tr><th>%a</th><td> iSpindel溫度 </td></tr><tr><th>%v</th><td> iSpindel電壓 </td></tr><tr><th>%t</th><td> Tilt值 </td></tr><tr><th>%u</th><td> 最後一次回報比重的時間 </td></tr><tr><th>%U</th><td> Temperature in C or F </td></tr><tr><th>%m</th><td> mode in integer </td></tr><tr><th>%M</th><td> mode in character </td></tr><tr><th>%P</th><td> Pressure in PSI </td></tr></table></div>

Related snippets