CodeIgniter Forums
Convert timestamp to tick - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Convert timestamp to tick (/showthread.php?tid=70200)

Pages: 1 2 3


Convert timestamp to tick - omid_student - 03-07-2018

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?


RE: Convert timestamp to tick - omid_student - 03-07-2018

Valid result for 2018-03-07 14:22:08 is 1520419928000 but mysql return 1520419928


RE: Convert timestamp to tick - Muzikant - 03-07-2018

(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.


RE: Convert timestamp to tick - Muzikant - 03-07-2018

(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.


RE: Convert timestamp to tick - omid_student - 03-07-2018

(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?


RE: Convert timestamp to tick - omid_student - 03-07-2018

(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


RE: Convert timestamp to tick - omid_student - 03-07-2018

(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?


RE: Convert timestamp to tick - InsiteFX - 03-08-2018

SEE: MICROSECOND

MySQL - Date and Time Functions


RE: Convert timestamp to tick - omid_student - 03-08-2018

(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?


RE: Convert timestamp to tick - InsiteFX - 03-08-2018

I found this article on stackoverflow:

CURRENT_TIMESTAMP in milliseconds

Which may be able to help you out.