Scoped GlideSystem - hoursAgo(Number hours)

Returns the date and time for a specified number of hours ago.

Table 1. Parameters
Name Type Description
hours Number Integer number of hours
Table 2. Returns
Type Description
String GMT in the format yyyy-mm-dd hh:mm:ss

if (current.operation() == 'insert') {
 // If no due date was specified, calculate a default
 if (current.due_date == '') {
 
  if (current.urgency == '1') {
   // Set due date to 4 hours ahead of current time
   current.due_date = gs.hoursAgo(-4);
  }
 
  if (current.urgency == '2') {
   // Set due date to 2 days ahead of current time
   current.due_date = gs.daysAgo(-2);
  }
 
  if (current.urgency == '3') {
   // Set due date to 7 days ahead of current time
   current.due_date = gs.daysAgo(-7);
  }
 }
}