Current Unix Timestamp SECONDS SINCE JAN 01 1970

Current UTC Time
2025-08-20
Convert Unix Timestamp to Datetime in Julia

How to convert Unix timestamp to Datetime in Julia

🎈 🎈 🎈
+1

    using Dates

    unix_timestamp = 1359812961
    date_time = unix2datetime(unix_timestamp)
    
    println("Converted Date: ", date_time)
        

Output:
Converted Date: 2013-02-02 13:49:21
Example only. There may be multiple ways to perform this operation.

Code Explanation

In this Julia example of Unix timestamp conversion, the unix2datetime() function converts the Unix timestamp '1359812961' to the date '2013-02-02 13:49:21'.
The unix2datetime() function takes the Unix timestamp as an argument and returns a DateTime object.



Other useful Julia date functions

Function Description Example
Date() Creates a Date object from year, month, and day. Date(2022, 5, 15) returns 2022-05-15
DateTime() Creates a DateTime object from year, month, day, hour, minute, and second. DateTime(2022, 5, 15, 8, 30, 45) returns 2022-05-15T08:10:45
now() Returns the current date and time as a DateTime object. now() returns 2024-08-28T12:34:56
today() Returns the current date as a Date object. today() returns 2024-08-28
unix2datetime() Converts a Unix timestamp to a DateTime object. unix2datetime(1652602245) returns 2022-05-15T08:10:45
datetime2unix() Converts a DateTime object to a Unix timestamp. datetime2unix(DateTime(2022, 5, 15, 8, 30, 45)) returns 1652602245
format() Formats a Date or DateTime object as a string according to the provided format string. Dates.format(Date(2022, 5, 15), "yyyy-mm-dd") returns 2022-05-15
Day() Represents a day period, which can be added or subtracted from dates. Date(2022, 5, 15) + Day(5) returns 2022-05-20
Month() Represents a month period, which can be added or subtracted from dates. Date(2022, 5, 15) + Month(2) returns 2022-07-15
Year() Represents a year period, which can be added or subtracted from dates. Date(2022, 5, 15) + Year(1) returns 2023-05-15
Current Unix Timestamp SECONDS SINCE JAN 01 1970

Current UTC Time
2025-08-20
Ad Banner Placeholder
Ad Banner Placeholder
Ad Banner Placeholder
Ad Banner Placeholder