View Full Version : Converting UTC Time

07-13-2009, 02:57 PM
New to the site but after some help with converting UTC time to a standard time format. I can code this using the system time but want to take the time from out of a log file, convert it from UTC to a standard format such as hh:mm:ss [17:15:00] and then display this on the GUI as the time in the log file -- without overwriting the acutal time in the log file itself if possible. Should be doable but trying to decipher the best way it should be done.

Using Javascript in the .cgi file to program this and it should work through clicking on a button called Convert_Time. This is where the system should read in the time from the log file. My view is to store this into a variable and then use this value with a standard UTC conversion method to convert into a standard format before then trying to display this time within the original context of the file.

E.G: The original line may read:
Error Condition from Device Logger at time [1247489745.4836]
and this should become:
Error Condition from Device Logger at time [Mon, 13 Jul 2009 12:55:45 GMT]


07-13-2009, 07:47 PM
this should get you started:

$time = sprintf "%s, %s %s %s %s", (split(/\s+/,gmtime(1247489745.4836)))[0,1,2,4,3];
print $time;