Bruce Gust
asked on
How and I format this date quickly and easily?
Here's what I'm using to get yesterday's date:
const yesterday_raw = new Date(new Date().setDate(new Date().getDate() - 1));
console.log(yesterday_raw) ;
It works fine, but I need to format it according to YYYY-MM-DD. I've seen a number of approaches on the Internet, but they all look kind of clunky.
I figured I would bring it before the ninjas and see if someone's got an easy way of formatting the above as YYYY-MM-DD.
Thoughts?
const yesterday_raw = new Date(new Date().setDate(new Date().getDate() - 1));
console.log(yesterday_raw)
It works fine, but I need to format it according to YYYY-MM-DD. I've seen a number of approaches on the Internet, but they all look kind of clunky.
I figured I would bring it before the ninjas and see if someone's got an easy way of formatting the above as YYYY-MM-DD.
Thoughts?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Short, simple and sweet!
Thank you!
isn't it amazing how some suggestions online can be so convoluted? One trip to EE and BAM! Problem solved!
Thanks again!
Thank you!
isn't it amazing how some suggestions online can be so convoluted? One trip to EE and BAM! Problem solved!
Thanks again!
var formattedDate = new Intl.DateTimeFormat("ko-KR
source : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat