Giter Club home page Giter Club logo

times's Introduction

times

golang的time辅助包

  1. 写此包的原因: Go原生的time包封装程度不够,用起来没那么顺手,而且Format很是奇怪,必须基于2006年1月2日15:04:05;此包是对time包的一些封装
  2. 实现方式:参照PHP的date()函数和strtotime()函数实现,使用方式也与这两个函数类似。

使用实例

  • 字符串转为time.Time类型:
t := times.StrToLocalTime("2012-11-12 23:32:01")
t := times.StrToLocalTime("2012-11-12")

原生的Go包这么实现:

t := time.Date(2012, 11, 12, 23, 32, 01, 0, time.Local)
t := time.Date(2012, 11, 12, 0, 0, 0, 0, time.Local)
  • time.Time类型格式化为字符串:
now := time.Now()
strTime := times.Format("Y-m-d H:i:s", now)

原生的Go包这么实现:

strTime := time.Now().Format("2006-01-02 15:04:05")

times's People

Contributors

polaris1119 avatar xianlihua avatar

Stargazers

Joseph chen avatar Clayton Kehoe avatar  avatar  avatar lixianxiang avatar debin avatar  avatar Wen avatar  avatar JeaYang avatar linnenn avatar 蔡兴兴 avatar Panda avatar cers avatar Mr.Fu avatar liosmt avatar  avatar  avatar Pitsanu L. avatar vabc avatar KaiscoL avatar wuguobao avatar purelightme avatar BoBin avatar zhougg avatar Jinlong Quan avatar dkeeper avatar leo avatar Wei.Jiang avatar gmdance avatar  avatar 张光明 avatar ZevFang avatar  avatar  avatar forging2012 avatar lianyang avatar  avatar luwei avatar 雪痕 avatar  avatar Xiaoyu avatar Yao Qi avatar Jianbo Sun avatar 穿山甲 avatar zuiguangyin avatar  avatar xjtdy888 avatar Matt Ma avatar Alix Axel avatar Prof Syd Xu avatar 碇逼 avatar axgle avatar Andy Cai avatar

Watchers

穿山甲 avatar James Cloos avatar  avatar Jinlong Quan avatar 90设计工作室 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.