Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #29524
    Eric Pement
    Participant

    Is there a function, macro, feature, or method in EmEditor to convert epoch seconds (in Unix, the number of seconds since the beginning of the epoch, defined as January 1, 1970 UTC) to human-readable date and time as ISO format (YYYY-MM-DD HH:MM:SS) ?
    I had some CSV data to handle with usernames, IP addresses, and timestamps as epoch seconds, and I wanted to convert that column to human-readable format.
    I couldn’t see how to do it in EmEditor, so in the end I used sed and then awk.

    Thanks for any suggestions.

    #29525
    David
    Participant

    Please try by using Find & Replace function:
    Find: \d+
    Replace: \J new Date(‘\0’)

    #29526
    Eric Pement
    Participant

    David, thanks for the suggestion, but it inserts the string “Invalid Date” into the replacement field.
    I am using the Replace command (Ctrl+H), or “Search > Replace” from the menubar on top, with “Wrap Around” checked and “Regular Expressions” chosen in the radio buttons

    I figured it out when I read the documentation on the JavaScript Date object. It wants milliseconds. Epoch seconds (Unix time) are literal seconds. They are not milliseconds.

    The solution worked when I changed the replace portion to: \J new Date(“\0” * 1000)

    #29527
    David
    Participant

    Thanks for sharing experience.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.