콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2321 화면

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
1767
1
11월 24
751
4
10월 24
2708
0
10월 22
4721
0
9월 22
38