regex date format yyyy-mm-dd code example
Example 1: js date format yyyy-mm-dd
yourDate.toISOString().split('T')[0]
Example 2: use regex to make sure it is a date
^[0-3]?[0-9]/[0-3]?[0-9]/(?:[0-9]{2})?[0-9]{2}$
yourDate.toISOString().split('T')[0]
^[0-3]?[0-9]/[0-3]?[0-9]/(?:[0-9]{2})?[0-9]{2}$