zoukankan      html  css  js  c++  java
  • time _ golang

    Go's offers extensive support for times and durations; here are some example

    package main
    
    import (
        "fmt"
        "time"
    )
    
    func main() {
    
        p := fmt.Println
    
        now := time.Now()
        p(now)
    
        then := time.Date(
            2009, 11, 17, 20, 34, 58, 651387237, time.UTC)
        p(then)
    
        p(then.Year())
        p(then.Month())
        p(then.Day())
        p(then.Hour())
        p(then.Minute())
        p(then.Second())
        p(then.Nanosecond())
        p(then.Location())
    
        p(then.Before(now))
        p(then.After(now))
        p(then.Equal(now))
    
        diff := now.Sub(then)
        p(diff)
    
        p(diff.Hours())
        p(diff.Minutes())
        p(diff.Seconds())
        p(diff.Nanoseconds())
    
        p(then.Add(diff))
        p(then.Add(-diff))
    }
    2015-03-25 14:12:14.302895576 +0800 CST
    2009-11-17 20:34:58.651387237 +0000 UTC
    2009
    November
    17
    20
    34
    58
    651387237
    UTC
    true
    false
    false
    46881h37m15.651508339s
    46881.62101430787
    2.8128972608584724e+06
    1.6877383565150833e+08
    168773835651508339
    2015-03-25 06:12:14.302895576 +0000 UTC
    2004-07-13 10:57:42.999878898 +0000 UTC
  • 相关阅读:
    HTML5元素标记释义
    Mvc使用Partial View 来封装上传控件
    订单页过滤,sql写法
    防止提交重复订单的方法
    查询数据库所有列
    asp.net 异常处理
    7. DateTime,TimeSpan
    8.1.thread
    8.2.Task
    2.2. Array
  • 原文地址:https://www.cnblogs.com/jackkiexu/p/4365569.html
Copyright © 2011-2022 走看看