Date format missing numerals


#1

hi! im looking to format date. [[Now.addDays(28).getFullYear()]]-[[Now.addDays(28).getMonth()]]-[[Now.addDays(28).getDate()]] gives me 2018-8-8, but i want it to show as 2018-08-08 ideas?


#2

Try this:

[[('x0' + Now.addDays(28).getMonth()).slice(-2)]]

Repeat for day

EDIT: Should be -2 not 2.


#3

tried it, didn’t work. now getting 2018-8-20 (since it adds to todays date.). Considering that month shows as “8” and no “08” i take it it didnt work
[[Now.addDays(28).getFullYear()]]-[[(‘x0’ + Now.addDays(28).getMonth()).slice(2)]]-[[(‘x0’ + Now.addDays(28).getDate()).slice(2)]]


#4

Yup my fault I had a typo. Should be -2 instead of 2.


#5

Ahh Excellent!

Many thanks sifu!

/Z


#6

Thanks for sharing this three years ago! Helped me big time!!