2

[Golang] Parse Unix Time (utime) Example

 2 years ago
source link: http://siongui.github.io/2017/02/16/go-parse-utime-timestamp/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Introduction

When I tried to get the timestamp of the Facebook post, I found that the timestamp is embedded in the data-utime attribute of abbr element:

<abbr title="Wednesday, February 15, 2017 at 7:00am" data-utime="1487113202" data-shorten="1" class="_5ptz"><span class="timestampContent">Yesterday at 7:00am</span></abbr>

The string 1487113202 looks familiar, so I did some googling [1] [7] and found that it represents Unix time, seconds and nanoseconds that have elapsed since January 1, 1970 UTC.

In this post, we will show how to parse the string of Unix time (also known as POSIX time or Epoch time) in Go programmming language.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK