zoukankan      html  css  js  c++  java
  • 4.2 时间格式转为字符串格式

    
    package main
    
    import (
    	"fmt"
    	"time"
    )
    
    func main() {
    	tTime := time.Date(2017, time.March, 5, 8, 5, 2, 0, time.Local)
    
    	// The formatting is done
    	// with use of reference value
    	// Jan 2 15:04:05 2006 MST
    	fmt.Printf("tTime is: %s
    ", tTime.Format("2006/1/2"))
    
    	fmt.Printf("The time is: %s
    ", tTime.Format("15:04"))
    
    	//The predefined formats could
    	// be used
    	fmt.Printf("The time is: %s
    ", tTime.Format(time.RFC1123))
    
    	// The formatting supports space padding
    	//only for days in Go version 1.9.2
    	fmt.Printf("tTime is: %s
    ", tTime.Format("2006/1/_2"))
    
    	// The zero padding is done by adding 0
    	fmt.Printf("tTime is: %s
    ", tTime.Format("2006/01/02"))
    
    	//The fraction with leading zeros use 0s
    	fmt.Printf("tTime is: %s
    ", tTime.Format("15:04:05.00"))
    
    	//The fraction without leading zeros use 9s
    	fmt.Printf("tTime is: %s
    ", tTime.Format("15:04:05.999"))
    
    	// Append format appends the formatted time to given
    	// buffer
    	fmt.Println(string(tTime.AppendFormat([]byte("The time is up: "), "03:04PM")))
    }
    
    /*
    tTime is: 2017/3/5
    The time is: 08:05
    The time is: Sun, 05 Mar 2017 08:05:02 CST
    tTime is: 2017/3/ 5
    tTime is: 2017/03/05
    tTime is: 08:05:02.00
    tTime is: 08:05:02
    The time is up: 08:05AM
    
    */
    
    
  • 相关阅读:
    qemu进程页表和EPT的同步问题
    Linux进程虚拟地址空间管理2
    qemu-kvm内存虚拟化1
    LInux进程虚拟地址空间的管理
    Linux下的文件系统2
    LInux中的文件系统1
    Linux IPC之管道通信
    操作系统中的特权级检查
    Linux下的信号机制
    进程的挂起、阻塞和睡眠
  • 原文地址:https://www.cnblogs.com/zrdpy/p/8620826.html
Copyright © 2011-2022 走看看