mysql中如何用datetime格式化数据?

datetime包含毫秒,要格式化输出,用fffDateTime t = DateTime.Now;Console.WriteLine(t.ToString("yyyy-MM-dd hh:mm:ss fff"));注:mysql里面的datetime类型的精确度是可以到1/ 10 ^ 6 秒的,某些客户端(如navicat for mysql)的显示经常只能看到精确到秒,其实是设计表的时候的配置问题。
mysql中如何用datetime格式化数据?
datetime包含毫秒,要格式化输出,用fffDateTime t = DateTime.Now;
Console.WriteLine(t.ToString("yyyy-MM-dd hh:mm:ss fff"));
注:mysql里面的datetime类型的精确度是可以到1/ 10 ^ 6 秒的,某些客户端(如navicat for mysql)的显示经常只能看到精确到秒,其实是设计表的时候的配置问题。

扩展资料:mysql中DateTime和Timestamp
DateTime
1、8个字节储存(8 bytes storage)
2、实际格式储存(Just stores what you have stored and retrieves the same thing which you have stored.)
3、与时区无关(It has nothing to deal with the TIMEZONE and Conversion.)
4、存储的时间范围为:'1000-01-01 00:00:00.000000' 到 '9999-12-31 23:59:59.999999'
Timestamp
1、4个字节储存(Time stamp value is stored in 4 bytes)
2、值以UTC格式保存( it stores the number of milliseconds)
3、时区转化 ,存储时对当前的时区进行转换,检索时再转换回当前的时区。
4、存储的时间范围为:'1970-01-01 00:00:01.000000' 到 '2038-01-19 03:14:07.999999'
2024-03-08
mengvlog 阅读 50 次 更新于 2025-10-30 05:22:05 我来答关注问题0
檬味博客在线解答立即免费咨询

mySQL相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部