Convert Unix Time to a Date Time Stamp

by Jul 14, 2025IT Tips0 comments

A MySQL database field with times similar to '1752463231.455827'

How to query the time and show it as '2025-07-14 17:22:28.911723'

1
2
3
4
5
6
7
8
9
10
11
-- set timezone
SET time_zone='Australia/Melbourne';
 
USE mydb;
 
SELECT
        created_on,
        from_unixtime(created_on) as event_melb_time
FROM
        mytable
        

How to tell the precision of Unix Time

Unix time is in seconds, but if there is a decimal point the following number of digits specifies the precision:

  • 1 digit: Tenths of a second = 1/10 of a second
  • 2 digits: Hundredths of a second = 1/100 of a second
  • 3 digits: Milliseconds  = A Millisecond is 1/1,000 of a second
  • 6 digits: Microseconds  = A Microsecond is 1/1,000,000 of a second
  • 9 digits: Nanoseconds = A Nanosecond is 1/1,000,000,000 of second

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.