drui0508 2018-11-23 12:13
浏览 4
已采纳

从天开始从时间接收字符串的简单方法.Now()

I'm trying to get the day as a string from a time.Now() instance.

now := time.Now() // .String() would give me the entire date as a string which I don't need
day := now.Day()) // is what I want but as a String.

So string(day) tells me "can not convert day to string".

For me now.Day().String() would be nice but there is no such method...

I could now try to take time.Now().String() and manipulate until the day is left over. But there should be a easier way to do it...

  • 写回答

2条回答 默认 最新

  • dongzhong8691 2018-11-23 12:18
    关注

    Use strconv to convert int to string

    strconv.Itoa(day)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用