Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2009
    Thanked 1 Time in 1 Post

    Converting UTC Time

    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]


  • #2
    Senior Coder
    Join Date
    Mar 2006
    Thanked 39 Times in 38 Posts
    this should get you started:

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


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts