匿名用户MYSQL CURRENT_TIMESTAMP 函数 返回的是TIMESTAMP类型的吗? 也有2038年的限制不?
CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP | Synonyms for NOW() |
|---|
Returns the current date and time as a value in ' or YYYY-MM-DD hh:mm:ss'YYYYMMDDhhmmss format, depending on whether the function is used in string or numeric context. The value is expressed in the session time zone.
If the fsp argument is given to specify a fractional seconds precision from 0 to 6, the return value includes a fractional seconds part of that many digits.
NOW() returns a constant time that indicates the time at which the statement began to execute. (Within a stored function or trigger, NOW() returns the time at which the function or triggering statement began to execute.) This differs from the behavior for SYSDATE(), which returns the exact time at which it executes.
In addition, the SET TIMESTAMP statement affects the value returned by NOW() but not by SYSDATE(). This means that timestamp settings in the binary log have no effect on invocations of SYSDATE(). Setting the timestamp to a nonzero value causes each subsequent invocation of NOW() to return that value. Setting the timestamp to zero cancels this effect so that NOW() once again returns the current date and time.
评论
有用 0哎! NOW() 函数实现 不太好找, 我找到NDB的实现
#ifdef NDB_MUTEX_STAT
static inline Uint64 now()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
}
BOOST
#ifndef NGS_CHRONO_H_
#define NGS_CHRONO_H_
#include <boost/date_time/posix_time/posix_time.hpp>
namespace ngs {
namespace chrono {
using boost::posix_time::milliseconds;
using boost::posix_time::seconds;
typedef boost::posix_time::ptime time_point;
typedef boost::posix_time::time_duration duration;
inline time_point now() {
return boost::posix_time::microsec_clock::universal_time();
}
不知道对不对 源码菜鸟
评论
有用 0
墨值悬赏

