datetime - Timestamp with a millisecond precision: How to save them in MySQL -
datetime - Timestamp with a millisecond precision: How to save them in MySQL -
i have develop application using mysql , have save values "1412792828893" represent timestamp precision of millisecond. is, amount of milliseconds since 1.1.1970. declare row timestamp
unfortunately didn't work. values set 0000-00-00 00:00:00
create table if not exists `probability` ( `id` int(11) not null auto_increment, `segment_id` int(11) not null, `probability` float not null, `measured_at` timestamp not null, `provider_id` int(11) not null, primary key (`id`) ) ;
how should declaration in order able save timestamp values precision?
you need @ mysql version 5.6.4 or later declare columns fractional-second time datatypes.
for example, datetime(3)
give millisecond resolution in timestamps, , timestamp(6) give microsecond resolution on *nix-style timestamp.
read this: http://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html
now(3)
give nowadays time millisecond precision.
if have number of milliseconds since unix epoch, seek datetime(3) value
from_unixtime(ms * 0.001)
javascript timestamps, example, represented in milliseconds since unix epoch.
mysql datetime timestamp milliseconds
Comments
Post a Comment