mysql如何在查询代码中转换int型的时间为正常的时间呢?

@Query("select a.id,a.title,a.author,a.pulblicTime from Articles a")
    Page<Articles> getAriticleList(Pageable pageable);

我尝试用

convert(char(20),a.pulblicTime,109)

或者

data_format(a.pulblicTime,"%Y-%M")

输出到前端还是长串的数字啊。

到底该怎么处理才是正常的字符串时间呢??

阅读 3.2k
2 个回答

select from_unixtime(int_time_stamp, '%y-%m-%d') from test;

新手上路,请多包涵

干嘛要用sql做,在entity中时间的get方法里处理不就好了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题