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方法里处理不就好了

推荐问题