Date/time field format problem when populating with additional minutes

CharlesR1
Kilo Guru

Hello,

I am having trouble with a date/time field. In our Incident application, we have a date/time field 'u_next_notification_due'. This field is populated by a business rule. When the business rule runs, the field should show the time as 30 minutes ahead of the current time. The script used for this functionality is:

'current.u_next_notification_due = gs.minutesAgo(-30);'

This works fine for the actual time, as this always shows the time as 30 minutes from now, however, the day, month and year are meaningless:

For example,when the business rule is run at 11-03-2014 12:00:29', the field shows the value '03-09-0016 12:30:29'.

I have tried everything I can think of to get this script to work, for example I also tried:

  1. var dte = current.date.getGlideObject();  
  2. current.date = dte.addSeconds(1800);  

....but I cannot seem to keep the date/month/year entry showing correctly.

What am I doing wrong?

Thanks for any help offered.

Charles

3 REPLIES 3

sach1
Tera Guru

Hi charlesr,



This issue may occur when the date format for system and user is different.



Try to log the date and check the date format. The Glide functions return date and time in GMT format.



also go through the below community links:


Client Script Date/Time Functions


Convert Date to Date Time



Regards,


Sachin


Is there a known reason why this happens with the user selects an alternate date/time format? There are lots of problem records in HI regarding date format issues, but is there one for this specifically?


The client side does not handle date formats because everything is treated as a string.   Server side the date objects are handled much better.



One thing that tends to happen on the server side is it enters the date and assumes GMT, which ends up being converted again giving the wrong value.



When setting the date on the server side, use current.date.setDisplayValue(newDate);