Current Unix Timestamp SECONDS SINCE JAN 01 1970

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

How to convert Unix timestamp to Date in R

🎈 🎈 🎈
+1

    unix_timestamp <- 1389818300
    date <- as.POSIXct(unix_timestamp, origin="1970-01-01", tz="UTC")
    print(date)
        

Output:
2014-01-15 20:38:20
Example only. There may be multiple ways to perform this operation.

Code Explanation

In this R example, the Unix timestamp 1389818300 is converted to a date using the as.POSIXct() function, specifying "1970-01-01" as the origin (the Unix epoch) and "UTC" as the time zone. This conversion gives you the corresponding date and time.
In this example, the output is 2014-01-15 20:38:20.


Other useful R date functions

Function Description Example
Sys.Date() Returns the current date. Sys.Date() returns 2024-08-28
Sys.time() Returns the current date and time as a POSIXct object. Sys.time() returns 2024-08-28 12:34:56
as.Date() Converts a character string to a Date object. as.Date('2024-08-28') returns 2024-08-28
as.POSIXct() Converts a date-time string or object to a POSIXct object, which represents the date and time in seconds since the Unix epoch. as.POSIXct('2024-08-28 12:34:56') returns 2024-08-28 12:34:56
as.POSIXlt() Converts a date-time string or object to a POSIXlt object, which stores date-time components as a list. as.POSIXlt('2024-08-28 12:34:56') returns a list with date-time components.
format() Formats a date or date-time object according to a specified format string. format(Sys.Date(), '%Y-%m-%d') returns 2024-08-28
difftime() Calculates the difference between two dates or date-time objects. difftime(Sys.time(), as.POSIXct('2024-08-28 12:00:00')) returns 0.5 hours
strptime() Parses a date-time string according to a specified format and returns a POSIXlt object. strptime('2024-08-28 12:34:56', '%Y-%m-%d %H:%M:%S') returns a POSIXlt object.
seq.Date() Generates a sequence of dates. seq.Date(from=as.Date('2024-08-28'), by='1 day', length.out=3) returns 2024-08-28, 2024-08-29, 2024-08-30
julian() Calculates the Julian date (days since origin) for a Date or POSIXct object. julian(as.Date('2024-08-28')) returns 20143 days since origin.
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