Welcome Guest, Not a member yet? Register   Sign In
Convert timestamp to tick
#1

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?
Reply
#2

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

(This post was last modified: 03-07-2018, 06:41 AM by Muzikant.)

(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.
Reply
#4

(This post was last modified: 03-07-2018, 06:45 AM by Muzikant.)

(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.
Reply
#5

(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?
Reply
#6

(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
Reply
#7

(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?
Reply
#8

SEE: MICROSECOND

MySQL - Date and Time Functions
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

(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?
Reply
#10

I found this article on stackoverflow:

CURRENT_TIMESTAMP in milliseconds

Which may be able to help you out.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB