top of page

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
dayname dd mmm yyyy
#txtDate5
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

Please wait ...
Unlock
Disclaimer: To the best of our knowledge, this code works for its stipulated purpose. If you find an error in our code, or know of a better way to achieve the same result - please contact us! All our code snippets come with full support to help you implement them on your own website - simply contact us for help.
bottom of page