Tagged: date, datestamp, epoch seconds, timestamp, unix
- AuthorPosts
- October 27, 2023 at 11:56 pm #29524Eric PementParticipant
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.
October 28, 2023 at 4:03 am #29525DavidParticipantPlease try by using Find & Replace function:
Find: \d+
Replace: \J new Date(‘\0’)October 28, 2023 at 11:07 am #29526Eric PementParticipantDavid, 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 buttonsI 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)
October 28, 2023 at 7:54 pm #29527DavidParticipantThanks for sharing experience.
- AuthorPosts
- You must be logged in to reply to this topic.