doukeyong3746487 2011-12-06 04:47
浏览 8
已采纳

Go中时间的格式

I have a go program like this,

package main

import "fmt"
import "time"

func main() {
s := strconv.Itoa64(time.Nanoseconds())
fmt.Println(s)
}

Here, in my system, the output is 19 digits nanoseconds. Now, I want to get the time like digits after 7 to 12 of those nanoseconds. Can anybody help how can it be possible in Go ?

NB: I want digits from 7 to 12 because in my system, time differs between them means other digits are same, so for me not needed. And formatting inside println is not required because I give example just to clarify my code. Actually, I will use formatted time for another purpose. I need it in s :=.

  • 写回答

3条回答 默认 最新

  • dongzhi6382 2011-12-06 05:20
    关注
    s := strconv.Itoa64(time.Nanoseconds())[6:12]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序