![]() The new Date() function can process strings in the format YYYY-MM-DD or YYYY/MM/DD. Sat 00:00:00 GMT+0530 (India Standard Time)Īs you see from the above examples, the only accepted string format for the date is 2021-05-/2/29. ![]() For example, refer to the code as follows: ![]() Other date formats may not be converted to a date object by this method. The string format needs to be YYYY-MM-DD, the ISO 8601 format, for it to work. When we pass a date in string format to the new Date(), it is converted into a date object. The most interesting part of the new Date('') function is that it can convert a date passed in a string format as an argument into a date format. The new Date() will return a date object as depicted by the date string passed as an argument. new Date() will return the current system date and time, including the timezone information in the local system time, if no parameter is passed to the new Date() function. new Date() takes arguments in various forms described below but returns a date object. The most commonly used way to convert a string to date is with the new Date() function.
0 Comments
Leave a Reply. |