コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
2801 ビュー

I need to obtain the create date of an order with the following format:

20070702 = YYYYMMDD

So far I was able to obtain the order's create date with the following code:

let order  = this.pos.get_order()

let order_date = order.creation_date

let formatted_date = order.creation_date.getFullYear() + order.creation_date.getMonth() + order.creation_date.getDate()

console.log(order_date)

console.log(formatted_date)

this outputs in the browser's console log like the following:

Fri Apr 17 2020 11:47:57 GMT-0400

2040

How do I get the date format I need?

アバター
破棄
最善の回答

var formatted_date  = order.creation_date.getFullYear() + ('00' + order.creation_date.getMonth()).slice(-2) + ('00' + order.creation_date.getDay()).slice(-2)

アバター
破棄
関連投稿 返信 ビュー 活動
1
4月 20
2203
1
11月 24
1368
4
10月 24
3604
0
10月 22
5123
0
9月 22
38