• 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
  • 相关阅读:
    Qt 解析EXcel文件
    Qt PC 安卓 tcp传输文件
    Qt listwigwt item 加入自定义元素
    Qt 独立运行时伴随CMD命令窗口
    xml模块
    shelve模块
    json模块 pickle模块
    sys 模块
    os模块
    添加变量
  • 原文地址:https://www.cnblogs.com/jackkiexu/p/4365569.html
Copyright © 2020-2023  润新知