Expand my Community achievements bar.

Javascript code to add current date and time in a textfield on click of a button

Avatar

Level 2

Hi,

I have done a lot of googling .....But could not found a viable solution to populate a text field in LC Designer ES 8.2 and above at runtime with the current date/time. on click of a button. I need Javascript code and not formcalc.

Please help .

Thanks

Kapil

2 Replies

Avatar

Level 5

I can help only for the current date.

var sDate = new Date();

this.rawValue = util.printd("dd.mm.yyyy", sDate);

Kind regards Mandy

Avatar

Level 5

I have found a solution for you - 3 variants for you:

Textfeld1.rawValue = util.printd("dd.mm.yyyy HH:MM", new Date());

Textfeld2.rawValue = util.printd("dddd d. mmmm yyyy HH:MM ", new Date());

Textfeld3.rawValue = util.printd("date{EEEE, D. MMMM YYYY} time(de){HH:MM:SS Z}", new Date(), true);

I hope this is helpfull,

Mandy