Javascript Date Methods
Date plays an important role in tracking moments when an event has occurred.
new Date() returns a Date object with current date and time(Ex: Sat Aug 05 2023 13:13:26 GMT+0530 (India Standard Time)).
const d = new Date("2023-03-24");//Date is 2023-03-24
const d = new Date();//
Below are the different kinds of date formats that are accepted(Y-Year;M-Month;D-Date)
-
ISO (YYYY-MM-DD)
const d = new Date("2024-06-29") -
Short (MM/DD/YYYY)
const d=new Date("06/29/2024"); -
Long (MMM DD YYYY )(DD MMM YYYY)
Note :- Month and Date order can be in any order.
- Separator can be anything, that will be ignored.
- Only 3 characters are considered in Month part.
const d=new Date("29 JUN 2024");const d=new Date("JUN 29 2024");const d=new Date("29*JUN*2024");//any separatorconst d=new Date("29 JUne 2024");//any case
Javascript allows Date manipulation with different methods.
Comments
Post a Comment