Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2811 มุมมอง

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)

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 20
2206
1
พ.ย. 24
1381
4
ต.ค. 24
3613
0
ต.ค. 22
5124
0
ก.ย. 22
38