Change date format of a catalog item variable date field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 02:50 AM - edited 11-28-2022 03:11 AM
Is there a way I can change the date format to this kind of format?
When I select a date it becomes like this
This is my date variable
Is it possible to add something/configure this script? I have this script cause I had to make it so it wont select the past date. Would it be possible to add something to these scripts so it will change the format to dd-Month(or MM)-YYYY
onChange Script:
Script Include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 07:54 AM
You can use getByFormat to change format of a date field. For example:
var date = new GlideDate(); //Outputs today's date in format 2024-01-29
var date2 = date.getByFormat('dd. MMMM, YYYY') //This outputs 29. January, 2024.
The getByFormat allows you to change the format quite a bit, for instance if you want a shorter output you could change it to ('dd. MMM, YY'). This would output 29. Jan, 24.
See the documentation for more info about it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 07:54 AM
You can use getByFormat to change format of a date field. For example:
var date = new GlideDate(); //Outputs today's date in format 2024-01-29
var date2 = date.getByFormat('dd. MMMM, YYYY') //This outputs 29. January, 2024.
The getByFormat allows you to change the format quite a bit, for instance if you want a shorter output you could change it to ('dd. MMM, YY'). This would output 29. Jan, 24.
See the documentation for more info about it.