I also noticed that my time is off the amount of the time zone. Bryon Baker Network Operations Manager Copesan - Specialists in Pest Solutions 800-267-3726 * 262-783-6261 ext. 2296 [email protected]<mailto:[email protected]> www.copesan.com<http://www.copesan.com/> "Servicing North America with Local Care"
From: [email protected] [mailto:[email protected]] On Behalf Of Bryon Baker Sent: Tuesday, April 22, 2014 11:14 AM To: RT Users ([email protected]) Subject: [rt-users] Issue with Time Hello all I need to know two things 1 What am I doing wrong with the code below as you can see I need to add a 1 to the month to get the correct month. 2 is there a more efficient way to manipulate dates in Request Tracker? Other than these question the code is working. The code my $self = shift; my $ticket = $self->TicketObj; my $datecreated = $ticket->CreatedObj->Unix; my $dateupdated = $ticket->LastUpdatedObj->Unix; my $datecreatedstr = $ticket->CreatedObj->AsString; my $dateupdatedstr = $ticket->LastUpdatedObj->AsString; my $dateresolved; my $dateresolvedstr; my $transactions = $ticket->Transactions; $transactions->Limit( FIELD => 'Type', VALUE => 'Status', FIELD => 'NewValue', VALUE => 'closed'); while (my $transaction = $transactions->Next) { $dateresolved = $transaction->CreatedObj->Unix; $dateresolvedstr = $transaction->CreatedObj->AsString; } print $datecreated," ",$dateupdated," ",$dateresolved, $dateresolvedstr,"\n"; my ($sec, $min, $hour, $day,$month,$year) = (localtime($dateresolved))[0,1,2,3,4,5]; $dateresolvedstr = ($year+1900)."-".($month+1)."-".$day." ".$hour.":".$min.":".$sec; print $dateresolvedstr,"\n"; $ticket->SetResolved($dateresolvedstr); print $datecreatedstr," b ",$dateupdatedstr," ",$year+1900,"-09-",$day," ",$hour,":",$min,":",$sec,"\n"; my $timeworked = ($dateresolved - $datecreated)/60 ; print $timeworked, "\n"; $ticket->SetTimeWorked($timeworked); return 1; Thanks for the help Bryon Baker Network Operations Manager Copesan - Specialists in Pest Solutions 800-267-3726 * 262-783-6261 ext. 2296 [email protected]<mailto:[email protected]> www.copesan.com<http://www.copesan.com/> "Servicing North America with Local Care"
-- RT Training - Dallas May 20-21 http://bestpractical.com/training
