top of page
Formatting Dates
ATTENTION: THIS IS OUR OLD SITE. TO SEE OUR NEW WEBSITE, CLICK HERE.
This code example shows how to format a date to DD/MM/YYYY for both individual and repeater display.
The following code formats a date of birth field to DD/MM/YYYY and displays it through a text field called txtBirthday. The formatting code is in the function formatFields(), which is called once the page and dbPeople dataset is ready. It checks if a date of birth is populated and hides the txtBirthday field if not. If the date of birth field is populated, then it formats the field as DD/MM/YYYY.
The following code formats the create date of news articles to DD/MM/YYYY for display on a repeater. The date format code is again housed in a function called formatFields(), which is called once the page and the dbArticles dataset is ready - and then still only after a short 200 millisecond delay. Within the formatFields() function, the formatting is done after the dbArticle items are individually ready. Finally, the formatted date is displayed on a text field called txtDate on the repeater.
Please login or sign-up (it's free!) to view our code. Refresh the page if already logged in.
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! We will help where we can, however please be aware that the code is provided 'as is' and without a promise of support in using or implementing it.
bottom of page