github.com/decred/politeia@v1.4.0/politeiawww/cmd/politeiawww_dbutil/time.go (about)

     1  // Copyright (c) 2022 The Decred developers
     2  // Use of this source code is governed by an ISC
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"time"
     9  )
    10  
    11  const (
    12  	// timeFormat contains the reference format that is used to print a human
    13  	// readable timestamp.
    14  	//
    15  	// Reference date: "Mon Jan 2 15:04:05 2006"
    16  	timeFormat = "2 Jan 2006 3:04:05pm"
    17  )
    18  
    19  // formatUnix formats a unix timestamp into a human readable string that is
    20  // formatted according to the timeFormat global variable.
    21  func formatUnix(unixTime int64) string {
    22  	t := time.Unix(unixTime, 0)
    23  	return t.Format(timeFormat)
    24  }