- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 10:16 PM
- Thanks for your help @Robert H @! Your script worked,but it gave yesterday’s date. I needed the current date and time, so I accepted the other answer. Appreciate your support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 05:18 AM - edited 05-26-2025 05:21 AM
Hello @Helan ,
Actually, all solutions presented here will give you the current date and time.
The difference is the time zone that this time is interpreted in.
My solution prints the date/time as per the time zone selected in the current user's profile. If you have not set your time zone correctly e.g. it's set to US/Pacific but you're actually located in India you will sometimes see yesterday's date. If you update your time zone setting to IST then the above code will print your exact local date and time.
The other solutions print the date/time as per the UTC time zone. This is IST -5:30 hours. So if you use that solution in the very early morning it will also print yesterday's date.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2025 08:12 AM
Hi @Helan Try below script I try in background script
var dt = new GlideDateTime();
gs.print("Current Date and Time: " +dt);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 07:37 PM
Thanks @Harish Bainsla ! This worked for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 07:32 PM
Please accept solution if it helps you