How to set the Date Format

msm4
Mega Guru

Hi,

I have written some Validation to the Date Field , i.e, The Date field should be filled by default on "Onload"   with some specific Date.

Everything is working fine except the Date Format. OnLoad the Date format is "YYYY_MM_DD" but on selection of any date, the format is different "DD_MM_YYYY".

I want the default Date format in "DD_MM_YYYY", how to set that , Can anyone please help me out.

Thanks in Advance.

BR.

Smitha

1 ACCEPTED SOLUTION

Since GlideDate() as well as GlideDateTime() always use yyyy-mm-dd, you can change the format of your return value of dat by just adding .getDisplayValue():



return dat.getDisplayValue();



That will give you the format of whatever the user has even if they are using something else such as mm-dd-yyyy


View solution in original post

9 REPLIES 9

Yes it does. If you want, just impersonate a different user, change their date format, then test your functionality.


Thank you Christopher. It worked.


Madhu27
Tera Expert

it comes from system property 'glide.sys.date_format'. you can change as per your requirement.


Ziaur Rahman1
Tera Expert

Hi Smitha,



Please set date format according to your requirement from system properties



System Properties- Basic Configuring- Date Format




Thanks


Ziaur Rahman


Madhu27
Tera Expert

  you can also use - setValueUTC(dt, format)



GlideDateTime - ServiceNow Wiki