Forum Discussion
DonnaWestwood
9 years agoCommunity Member
Javascript date format dd/mm/yy NOT dd/mm/yyyy - do I need to import a library?
I am developing a software simulation which uses dates/ calendars extensively. (a booking system) Some javascript has already been used in this project, for example system date, year, month, day of ...
OwenHolt
9 years agoSuper Hero
To answer part 1 of your question, you current JavaScript probably contains some script similar to this to get the system date: var today = new Date();
and something like this to isolate the year: var yyyy = today.getFullYear();
To convert the year to 2 digits, change the value returned for the year above into a string and then create a substring of that using the last 2 digits like this: var yyyy = today.getFullYear().toString().substr(-2);
For part 2, I need more info. How are they choosing the date? Do they type in the full date in an entry field or fields? Do they click a date on a calendar? Do they choose a date from a list of available dates?