mysql 查询时间戳格式化


时间搓格式化
select id,name,FROM_UNIXTIME(time,'%Y-%m-%d %H:%i:%s') as addtime from testtable where totaltime != '';

//time是时间戳字段,查出来之后是格式化的数据 ,重命名为 addtime

查询的时候可以把时间格式变成时间戳

select id,name,UNIX_TIMESTAMP(time) as addtime from testtable1; //我的数据库存的time格式是这样的 :2019-02-27

 

每次用的时候,找也找不到,还是保存到自己的随笔中。。。

来源:https://www.cnblogs.com/xbxxf/p/11114426.html

mysql 获取时间搓,和转换

sql:SELECT unix_timestamp(now());

结果:1506669159

获得的时间戳为秒

格式化当前时间

sql:SELECT FROM_UNIXTIME(unix_timestamp(now()), '%Y-%m-%d %H:%i:%S');

结果:2017-09-29 15:15:29

原文链接:https://blog.csdn.net/lyg_come_on/article/details/78134083

获取当前系统时间

1.获取当前日期+时间
  now();
  sysdate();
  这两个函数都是获取日期+时间,不同之处在于:now()在执行开始时值就得到了,sysdate()在函数执行时动态得到值
 
2.获取当前日期:
  curdate();
  current_date();
  current_date;
3.获取当前时间:
  curtime();
  current_time();
  current_time;
 
4.获取UTC时间
  A.获取UTC日期:utc_date();
  B.获取UTC时间:utc_time();
  C.获取UTC日期+时间:utc_timestamp;

 

 

 

 

posted on 2019-11-06 18:06  少杨  阅读(11074)  评论(0编辑  收藏  举报