1

I have been searching for a library in JS where I get the output as date format pattern ('yyyy-mm-dd' or 'dd-mm-yyyy' or so on..) from a date as input. the date could be in string format or UNIX. i.e if we paas date in some dateFormat('2021-08-14') function then output would be yyyy-mm-dd or so on.

If anyone has any idea about this then please let me know I know I can achieve this with regex but I want a build library in JS. Thanks in advance

user3546665
  • 41
  • 1
  • 6

2 Answers2

0

momentjs was the most popular for this but is no longer maintained, https://day.js.org/ or https://date-fns.org/ are good alternatives.

gvdp
  • 86
  • 3
0

The Date prototype has a good function for this: Date.prototype.toDateString
If you create an instance of Date, then you can call toDateString on it, and you have your

2pichar
  • 1,348
  • 4
  • 17