GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dropwhile/gostrftime: [moved to codeberg] strftime for Go

This repository was archived by the owner on Dec 18, 2025. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

72 Commits
72 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.gitignore
.gitignore
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
example_test.go
example_test.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
gostrftime.go
gostrftime.go
 
 
gostrftime_test.go
gostrftime_test.go
 
 

Repository files navigation

gostrftime

Important

Moved to codeberg!

About

A Go pkg for formatting time.Time in an strftime(3) like way. Basically, strftime for Go, with a couple of additions.

Installing

$ go get github.com/cactus/gostrftime

Supported formats:

code example Description
%A Sunday full weekday name
%a Sun abbreviated weekday name
%B September full month name
%b Sep abbreviated month name
%C 20 (year / 100) as number. Single digits are preceded by zero
%D 09/21/14 equivalent to %m/%d/%y
%d 21 day of month as number. Single digits are preceded by zero
%e 21 day of month as number. Single digits are preceded by a blank
%f 001234 microsecond as a six digit decimal number, zero-padded on the left
%F 2014-09-21 equivalent to %Y-%m-%d
%H 15 the hour (24 hour clock) as a number. Single digits are preceded by zero
%h Sep same as %b
%I 03 the hour (12 hour clock) as a number. Single digits are preceded by zero
%j 264 the day of the year as a decimal number. Single digits are preced by zeros
%k 15 the hour (24 hour clock) as a number. Single digits are preceded by a blank
%L 001 millisecond as a three digit decimal number, zero-padded on the left
%l 11 replaced by the hour (12 hour clock) as a number. Single digits are preceded by blank
%M 32 replaced by the minute as a decimal number. Single digits are preceded by a zero
%m 09 replaced by the month as a decimal number. Single digits are preceded by a zero
%N 001234567 nanosecond as a 9 digit decimal number, zero-padded on the left
%n \n a newline
%P am am or pm as appropriate
%p AM AM or PM as appropriate
%R 15:32 equivalent to %H:%M
%r 03:32:05 AM equivalent to %I:%M:%S %p
%S 05 the second as a number. Single digits are preceded by a zero
%s 1461497457 the number of seconds since the Epoch, UTC
%T 15:32:05 equivalant to %H:%M:%S
%t \t a tab
%v 21-Sep-2014 equivalent to %e-%b-%Y
%w 0 the weekday (Sunday as first day of the week) as a number
%Y 2014 replaced by the year with century as a number
%y 14 year without century as a number. Single digits are preceded by zero
%Z UTC time zone name
%z -0700 the time zone offset from UTC

Using

import (
    "fmt"
    "time"
    "github.com/cactus/gostrftime"
)

func main() {
    now := time.Now()
    fmt.Println(gostrftime.Format("%Y-%m-%d", now))
}

License

Released under an ISC license. See LICENSE.md file for details.

About

[moved to codeberg] strftime for Go

codeberg.org/dropwhile/gostrftime

Topics

gostrftimetime

Resources

Readme
ISC license
Activity

Stars

27 stars

Watchers

2 watching

Forks

7 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.