Results 1 to 5 of 5

Thread: How to convert epoch time to human

  1. #1
    Join Date
    Jul 2009
    Posts
    30

    How to convert epoch time to human

    Hello friends,

    I want a UNIX function where i want to convert epoch column into to date the form (DD / MM / YYYY HH24: MI: SS). For example if my input is epoch ==> 1264712387 Input: epoch ==> 1264712387 then my output has to be as 28/01/201 0 20:59:47 output : 28/01/201 0 20:59:47 . Does anyone know how to do it.

  2. #2
    Join Date
    Jan 2009
    Posts
    126

    How to convert epoch time to human

    If you want to convert epoch time to human then i would suggest you to use the following code, hope you get some idea from here

    Code:
    cat file |while read EPOCH
    do
    READABLE=`gawk 'BEGIN{print strftime("%c", $EPOCH )}'` 
    READABLE=`gawk 'BEGIN{print strftime("%c",123456)}'` 
    echo $READABLE
    done

  3. #3
    Join Date
    Dec 2008
    Posts
    128

    Convert epoch time to human

    I have one question can you tell me why did you use loop when gawk can get the whole thing without the loop
    Code:
    READABLE=$(gawk '{print strftime("%c", $0)}')
    echo $READABLE
    and if you want you can convert epoch seconds to whatever time format you want by using the below code

    Code:
    #!/usr/bin/ksh93
    
    while read EPOCH
    do
       printf "%T\n" '#'${EPOCH}
    done < file

  4. #4
    Join Date
    Jul 2009
    Posts
    18

    How to convert epoch time to human

    I am also facing similar type of issue my friend where i am having epoch UTC time format an now i want to convert it back to human readable using C #, i know that it's possible and here is the epoch time which i had created it epoch = 1225815911 and now i wan to convert it back to human readable time. Thanks in Advance.

  5. #5
    Join Date
    Jan 2009
    Posts
    86

    Convert epoch time to human

    Till my knowledge if you want to convert from epoch UTC to human readable time, then you need to find the number difference between DateTime class' base time to epoch time. After that you need to multiply your epoch time by the tick resolution and then add your base ticks. Now finally you have to pass the ticks into the DateTime constructor and get a nice human-readable result

Similar Threads

  1. How to convert UTC timestamp value to date and time
    By AsceTic! in forum MS Office Support
    Replies: 2
    Last Post: 02-02-2012, 07:14 PM
  2. Replies: 2
    Last Post: 25-01-2012, 07:59 PM
  3. Replies: 4
    Last Post: 24-08-2011, 10:34 AM
  4. Replies: 1
    Last Post: 24-08-2011, 04:41 AM
  5. How to convert Date and Time Formats in VB.Net
    By Jamaima in forum Software Development
    Replies: 4
    Last Post: 08-07-2010, 06:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,726,871,355.40502 seconds with 16 queries