![]() Now let's see how to use the toJSON() method, which returns our date in the yyyy-mm-dd format in addition to the time format, hh:mm:ss.ms. We just saw how to get the current date using date methods. Suppose we don't want to make use of dash(-) between our date values, all we have to do is replace the dash with whatever we prefer. ![]() Note: We added one to the date.getMonth()'s value since it’s 0-based indexing. This arrangement can be altered based on how we want the date's format to appear. Let’s now put all these together based on the format in which we want our date to appear: const date = new Date()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |