---
original_url: "https://jace.pro/blog/service-portal-validating-date-format/"
format: markdown
ai_optimized: true
---

Service Portal: Validating Date Format# Service Portal: Validating Date Format

August 16, 2018 [servicenow ](/tags/servicenow/)[service-portal](/tags/service-portal/)

  Enable AI AnimationSomeone had asked how to do some “[How to verify a date format in service portal?](https://community.servicenow.com/community?id=community_question&sys_id=71098fa1db5cdbc01dcaf3231f961929)”

This came up in a chat I was having this week.

To use the `g_user_date_format`, `g_user_date_time_format` and `getDateFromFormat()`, you would have to re-include the JS file that declares these variables.

To do that go to the widget where you get a failure message and add a new dependency to a new UI script where you copy/paste the code from [https://hi.service-now.com/scripts/calendar.js](https://hi.service-now.com/scripts/calendar.js).

Then all your old calls ought to work as described in other posts.

`// returns a date object you can test against for date/time 
// variables/fields
new Date(getDateFromFormat(newValue, g_user_date_time_format));

// returns a date object you can test against for date 
// variables/fields
new Date(getDateFromFormat(newValue, g_user_date_format));`
---
[View this page on GitHub](https://github.com/jacebenson/jace.pro/tree/main/./src/posts/2018/2018-08-16-service-portal-validating-date-format.md).

[Service Portal: Validating Date Format](https://jace.pro/blog/service-portal-validating-date-format/) [Jace Benson](https://jace.pro) ![Jace Benson](https://jace.pro/icon-512x512.png)

---

*This content is from Jace Benson's ServiceNow and tech blog at jace.pro*
*Original post: https://jace.pro/blog/service-portal-validating-date-format/*
