gautamlakum
gautamlakum

Reputation: 12015

How to save time in milli-seconds in mysql?

I am working on an API (PHP) which provides me time in Minutes:Seconds:Milli-seconds format (01:21:91). I don't know how to save it in mysql. I also need to make some operations in that time. Please help me with this.

Upvotes: 0

Views: 255

Answers (1)

CodeFanatic
CodeFanatic

Reputation: 11474

Since you are not working with mySQL 5.6 or higher you have to split it into two columns. The one for the datetime (dttme) and the other one for the microsecond (mcrscnds)

CREATE TABLE microseconds (
  dttme datetime,
  mcrscnds int
);

INSERT INTO microseconds VALUES
  ('2014-05-15 09:22:37.456789', MICROSECOND('2014-05-15 09:22:37.456789'));

Upvotes: 2

Related Questions