How do I get the current date in the current users format in Jelly

rahul101
ServiceNow Employee
ServiceNow Employee

In my UI Page I am getting the current date using.

var gdt = new GlideDateTime();

  var date = gdt.getLocalDate();

if the user has a date format other than yyyy-dd-mm, system simply picks up wrong data when entering the "date" into database. on the client side i could use "g_user_date_format". What is the best way if getting the date in user's format.

Thanks,

1 REPLY 1

mike_allgire
Giga Guru

If you are just trying to print out the current date/time, then you should just be able to use something like this. I tested it in Fuji and it changes the structure accordingly. If it is the user's current session, then it should be fine.


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


      This should show the date as ${gs.now();}<br/>


      This should show the date/time as ${gs.nowDateTime();}


</j:jelly>