How to getHours

chanikya
Tera Guru

Hi,

some one please suggest me how to get Hours only from  new GlideDateTime()).getLocalTime().

all client  systems are running in PST zone.

1 ACCEPTED SOLUTION

Edited the script

 

if (gdt.getDayOfWeekUTC() == 2) //Tuesday 2 7AM PST (-7)
{

	if (gdtH.getHourOfDayUTC() == 14) {//GMT
		email.setSubject("Gentle Reminder for TimeCard Approval of the week starts on " + par1.lastWeek);
		email.addAddress("cc", par1.manager_email, par1.manager_name);
		template.print('Hi ' + par1.user + ',</br></br>This is a gentle reminder, that the Timecards in Submitted State are overdue, for the week starts on, "' + par1.lastWeek + '" in the system. Kindly Approve or Reject the timecards last by 3PM PST. </br></br>');
		template.print('<br/>');
	}
}
if (gdt.getDayOfWeekUTC() == 3) //Wednesday 3 1AM = tuesday 2 6PM PST (-7)
{
	if (gdtH.getHourOfDayUTC() == 1) { //GMT
		email.setSubject("Final Reminder for TimeCard Approval of the week starts on " + par1.lastWeek);
		email.addAddress("cc", par1.manager_email, par1.manager_name);
		template.print('Hi ' + par1.user + ',</br></br>This is a final reminder, that timecard approval for the below Employees are overdue for the week starts on, "' + par1.lastWeek + '" in the system and needs immediate approval. </br></br>');
		template.print('<br/>');
	}
}

View solution in original post

40 REPLIES 40

var gdt = new GlideDateTime();
var gt = gdt.getTime();
gs.info("DayOf Test:" + gt.getHourOfDayLocalTime());

returning PST time 13Hours  

 

 

To avoid all confusion, convert the pst time into gmt and use 

gt.getHourOfDayUTC()

 

f (gdt.getDayOfWeekLocalTime() == 2) //Tuesday 2 7AM PST , 18 PM PST
{

if (gdtH.getHourOfDayLocalTime() == 7) { //GMT - 14
email.setSubject("Gentle Reminder for TimeCard Approval of the week starts on " + par1.lastWeek);
email.addAddress("cc", par1.manager_email, par1.manager_name);
template.print('Hi ' + par1.user + ',</br></br>This is a gentle reminder, that the Timecards in Submitted State are overdue, for the week starts on, "' + par1.lastWeek + '" in the system. Kindly Approve or Reject the timecards last by 3PM PST. </br></br>');
template.print('<br/>');
}

if (gdtH.getHourOfDayLocalTime() == 18) { //GMT - 1 , wednesday 3
email.setSubject("Final Reminder for TimeCard Approval of the week starts on " + par1.lastWeek);
email.addAddress("cc", par1.manager_email, par1.manager_name);
template.print('Hi ' + par1.user + ',</br></br>This is a final reminder, that timecard approval for the below Employees are overdue for the week starts on, "' + par1.lastWeek + '" in the system and needs immediate approval. </br></br>');
template.print('<br/>');
}

}

i Agreed with you in this point.

 

Kindly suggest me Hours format, always it has to use system timezone only, take system timezone hours only.

system timezone might be anything (iST or CST or GMT or PST or UTC or MTC ), but always it has to use Sysem timezone. 

kindly help me this way.

Edited the script

 

if (gdt.getDayOfWeekUTC() == 2) //Tuesday 2 7AM PST (-7)
{

	if (gdtH.getHourOfDayUTC() == 14) {//GMT
		email.setSubject("Gentle Reminder for TimeCard Approval of the week starts on " + par1.lastWeek);
		email.addAddress("cc", par1.manager_email, par1.manager_name);
		template.print('Hi ' + par1.user + ',</br></br>This is a gentle reminder, that the Timecards in Submitted State are overdue, for the week starts on, "' + par1.lastWeek + '" in the system. Kindly Approve or Reject the timecards last by 3PM PST. </br></br>');
		template.print('<br/>');
	}
}
if (gdt.getDayOfWeekUTC() == 3) //Wednesday 3 1AM = tuesday 2 6PM PST (-7)
{
	if (gdtH.getHourOfDayUTC() == 1) { //GMT
		email.setSubject("Final Reminder for TimeCard Approval of the week starts on " + par1.lastWeek);
		email.addAddress("cc", par1.manager_email, par1.manager_name);
		template.print('Hi ' + par1.user + ',</br></br>This is a final reminder, that timecard approval for the below Employees are overdue for the week starts on, "' + par1.lastWeek + '" in the system and needs immediate approval. </br></br>');
		template.print('<br/>');
	}
}

i have two trigger points on Tuesday only 7AM morning , 6PM evening