Format Dates
Learn how to format dates using Corvid (a.k.a. Wix Code).
This example shows you how to format a date selected by user input in various ways depending on your preference. Try the example below.
#iptDate
Try it!
dd/mm/yyyy
#txtDate1
#txtDate2
dd month yyyy
#txtDate3
dd mmm yyyy
#txtDate4
#txtDate5
dayname dd mmm yyyy
dayname
Add an onChange event listener for #iptDate to listen for user entry and format the date accordingly. The toLocaleDateString function performs the formatting. The parameter "en-GB" specifies the language format to be Great British English - you can change this to suit your preference. The options parameter specifies the format for the date itself e.g. dd/mm/yyyy or various others. Five date format examples are provided in this example.
Page Code