Giter Site home page Giter Site logo

timeformat's Introduction

timeformat GoDoc Build Status

An easy to remember time format layout for go.

Layout

timeformat default
YYYY 2006
YY 06
MMMM January
MMM Jan
MM 01
M 1
DD 02
D 2
hh 03
HH 15
h 3
wwww Monday
www Mon
mm 04
m 4
ss 05
s 5
f 0 (.fff = .000)
F 9 (.FFF = .999)
a pm
A PM
z MST
-Z:Z:Z -07:00:00
Z:Z:Z Z07:00:00
-Z:Z -07:00
Z:Z Z07:00
-ZZZ -070000
ZZZ Z070000
-ZZ -0700
ZZ Z0700
-Z -07
Z Z07

Example 1

package main

import (
	"fmt"
	"time"

	"github.com/v4run/timeformat"
)

func main() {
	t := time.Date(2017, time.January, 1, 0, 0, 0, 0, time.UTC)
	fmt.Println(timeformat.T(t).Format("www MMM D HH:mm:ss -ZZ z YYYY"))
}

Output

Sun Jan 1 00:00:00 +0000 UTC 2017

Example 2

package main

import (
	"fmt"

	"github.com/v4run/timeformat"
)

func main() {
	fmt.Println(timeformat.Layout("www MMM D HH:mm:ss -ZZ z YYYY"))
}

Output

Mon Jan 2 15:04:05 -0700 MST 2006

Installation

go install github.com/v4run/timeformat/cmd/gotimeformat@latest

timeformat's People

Contributors

v4run avatar

Stargazers

Oleg Balunenko avatar  avatar whai avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.