- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'd like to get today's date using a client script.
If anyone knows how, please let me know.
The conditions are as follows:
・Get in Japan time(JST)
・Get in yyyymmdd format
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
You can easily get and display the users time through the javascript Date() object.
A simple example:
var date = new Date();
g_form.addInfoMessage('Current date: ' + date.getFullYear() + (date.getMonth()+1) + date.getDate());
// the +1 to the month is because the months are numbered as 0-11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @user_ms
You need to convert :
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
what's your actual business requirement?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @user_ms,
please refer to this:
Understanding GlideDate() and GlideDateTime() in ServiceNow
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Try below script
function getTodayInJST() {
// Get current local time
var now = new Date();
// Convert to UTC by adjusting with local timezone offset
var utc = now.getTime() + (now.getTimezoneOffset() * 60000);
// JST is UTC + 9 hours = 9 * 60 * 60 * 1000 ms
var jstOffset = 9 * 60 * 60 * 1000;
// Create a new Date object for JST
var jstDate = new Date(utc + jstOffset);
// Format components to yyyyMMdd
var year = jstDate.getFullYear();
var month = ('0' + (jstDate.getMonth() + 1)).slice(-2);
var day = ('0' + jstDate.getDate()).slice(-2);
return '' + year + month + day;
}
// Example usage in a client script
function onLoad() {
var jstToday = getTodayInJST();
console.log('Today (JST) in yyyymmdd:', jstToday);
// You can also set it on a field, e.g.:
// g_form.setValue('your_date_field', jstToday);
}
Regards,
Musab