Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

change datetime format

Wade Clairmont
Tera Guru

Lots of posts our there to bring datetime format back to system format, all fine a good, but how can I go the other way,

I need to convert the format from system default format to a custom format

from:  yyyy-mm-dd hh:mm:ss

to: E MMM dd yyyy HH:mm

3 REPLIES 3

sachin_namjoshi
Mega Patron

Jaspal Singh
Mega Patron

Hi Wade,

 

I would use below.

var newDate = 'Monday, June 10, 2020 11:00 AM';
var gdt = new GlideDateTime();

gdt.setDisplayValue(newDate,'E, MMMM dd, yyyy HH:mm');

var dateTimeForField = gdt.getDisplayValue();
gs.print(dateTimeForField);

 

Also, look link that I always prefer for a check.

This is all good, but how would change input 2020-06-08 11:51     

to      Mon, June 8, 2020 11:51