Giter VIP home page Giter VIP logo

timeformat's Introduction

timeFormat

让JavaScript如PHP般格式化时间

使用方法:

util.timeFormat(dateObj, 'pattern')

支持的时间格式:

年:YYYY {2013} YY {13}

月:MM {12}、{02} M {12}、{2}

日:DD {20}、{08} D {20}、{8}

时:hh {11}、{05} h {11}、{5}

分:mm {37}、{03} m {37}、{3}

秒:ss {59}、{06} s {59}、{6}

毫秒:msss {597}、{006} ms {597}、{6}

支持的分隔符:

  • / 单个空格 : .

由支持的时间格式与分隔符任意组合作为第二个参数pattern

例子:

var time = new Date(1370257374452);

util.timeFormat(time, 'YYYY-MM-DD hh:mm:ss'); //output 2013-06-03 19:02:54

util.timeFormat(time, 'h:m'); //output 19:2

util.timeFormat(time, 'MM.DD YYYY h-m-s:ms'); //output 06.03 2013 19-2-54:452

timeformat's People

Contributors

dnxbf321 avatar

Watchers

 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.