CodeIgniter Forums

Full Version: Convert timestamp to tick
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hello guys
In my database,I have record that contain timestamp field
Example 2018-12-1 12:12:1

Now i need use it in my app and get elapsed time from this date
When i use FROM_UNIXTIME,it return invalid result
Why?
Valid result for 2018-03-07 14:22:08 is 1520419928000 but mysql return 1520419928
(03-07-2018, 06:14 AM)omid_student Wrote: [ -> ]Hello guys
In my database,I have record that contain timestamp field
Example 2018-12-1 12:12:1

Now i need use it in my app and get elapsed time from this date
When i use FROM_UNIXTIME,it return invalid result
Why?

Maybe because of wrong format. Change this "2018-12-1 12:12:1" to this "2018-12-01 12:12:01" and try again.
(03-07-2018, 06:18 AM)omid_student Wrote: [ -> ]Valid result for 2018-03-07 14:22:08 is 1520419928000 but mysql return 1520419928

The valid timestamp for "2018-03-07 14:22:08" should be 1520432528. Try it by yourself on Unix Time Stamp.

Timestamp 1520419928000 is for "50150-03-10 20:53:20". The result from database is more current, but it still looks wrong.
(03-07-2018, 06:42 AM)Muzikant Wrote: [ -> ]
(03-07-2018, 06:18 AM)omid_student Wrote: [ -> ]Valid result for 2018-03-07 14:22:08 is 1520419928000 but mysql return 1520419928

The valid timestamp for "2018-03-07 14:22:08" should be 1520432528. Try it by yourself on Unix Time Stamp.

Timestamp 1520419928000 is for "50150-03-10 20:53:20". The result from database is more current, but it still looks wrong.
Why when i use 1520419928000 and convert to date,result is valid why?
(03-07-2018, 06:42 AM)Muzikant Wrote: [ -> ]
(03-07-2018, 06:18 AM)omid_student Wrote: [ -> ]Valid result for 2018-03-07 14:22:08 is 1520419928000 but mysql return 1520419928

The valid timestamp for "2018-03-07 14:22:08" should be 1520432528. Try it by yourself on Unix Time Stamp.

Timestamp 1520419928000 is for "50150-03-10 20:53:20". The result from database is more current, but it still looks wrong.
I'm sorry i had mistake,the 1520419928000 is millisecond of date Huh
Thanks
(03-07-2018, 06:42 AM)Muzikant Wrote: [ -> ]
(03-07-2018, 06:18 AM)omid_student Wrote: [ -> ]Valid result for 2018-03-07 14:22:08 is 1520419928000 but mysql return 1520419928

The valid timestamp for "2018-03-07 14:22:08" should be 1520432528. Try it by yourself on Unix Time Stamp.

Timestamp 1520419928000 is for "50150-03-10 20:53:20". The result from database is more current, but it still looks wrong.

How do i can convert datetime to millisecond in mysql?
(03-08-2018, 04:50 AM)InsiteFX Wrote: [ -> ]SEE: MICROSECOND

MySQL - Date and Time Functions

Thanks but the result for 2018-03-07 14:22:08 is 0 why?
I found this article on stackoverflow:

CURRENT_TIMESTAMP in milliseconds

Which may be able to help you out.
Pages: 1 2 3