需求:PostgreSQL中有四种获取当前时间的方式。
解决方案:
1.now()

返回值:当前年月日、时分秒,且秒保留6位小数。
2.current_timestamp

返回值:当前年月日、时分秒,且秒保留6位小数。(同上)
申明:now和current_timestamp几乎没区别,返回值相同,建议用now。
3.current_time

返回值:时分秒,秒最高精确到6位
4.current_date

返回值:年月日
本文详细介绍了PostgreSQL中获取当前时间的四种方法:now()、current_timestamp、current_time及current_date,对比了它们的返回值及精度,推荐使用now()函数。
1.now()

返回值:当前年月日、时分秒,且秒保留6位小数。
2.current_timestamp

返回值:当前年月日、时分秒,且秒保留6位小数。(同上)
申明:now和current_timestamp几乎没区别,返回值相同,建议用now。
3.current_time

返回值:时分秒,秒最高精确到6位
4.current_date

返回值:年月日
2732
3万+
4829
3394

被折叠的 条评论
为什么被折叠?
