How to Get Today's Date in MM-DD-YYYY Format in ServiceNow
- ericpark68
- Mar 18
- 1 min read
Updated: Mar 29

Proper date formatting in ServiceNow scripts ensures accuracy, clarity, and consistency, particularly when working with international teams or integrations. This article demonstrates how to obtain today's date in the MM-DD-YYYY format, commonly used in various business scenarios, using ServiceNow scripting methods.
Understanding Date Formatting in ServiceNow
ServiceNow uses two main classes for date handling:
GlideDate: Manages date values without time information, ideal for date-only fields.
GlideDateTime: Includes date and time components, suitable for timestamp fields.
For date-only operations, GlideDate is typically simpler and more straightforward.
Correct Way to Retrieve Today's Date
Here's a simple and verified method to get today's date formatted as MM-DD-YYYY:
var currentDate = new GlideDate();
var formattedDate = currentDate.getByFormat("MM-dd-yyyy");
gs.info("Today's date: " + formattedDate);
Alternative Approaches & Troubleshooting
Using GlideDateTime: If working with timestamps, extract the date:
var gdt = new GlideDateTime();
var today = gdt.getDate();
var formattedDate = today.getByFormat("MM-dd-yyyy");
Common issues:
Ensure uppercase MM for month and lowercase dd for day.
Avoid mixing date and time formatting symbols.
Conclusion
To reliably format dates in ServiceNow, using GlideDate's getByFormat() method is recommended. This ensures clarity, reduces errors, and simplifies scripting tasks. Implementing these best practices helps maintain data consistency across your ServiceNow instance.