Current Unix Timestamp SECONDS SINCE JAN 01 1970

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

How to convert Unix timestamp to Datetime in Haxe

🎈 🎈 🎈
+1

    class Main {
        static function main() {
            // Convert Unix timestamp to Date
            var unixTimestamp:Float = 1723530215;
            var date:Date = Date.fromTime(unixTimestamp * 1000);
            
            trace("Converted Date: " + date);
        }
    }            
        

Output:
Converted Date: 2024-08-13 06:23:35
Example only. There may be multiple ways to perform this operation.

Code Explanation

In this example of Unix timestamp to date conversion in Haxe, the Unix timestamp '1723530215' is multiplied by 1000 to convert it from seconds to milliseconds.
The Date.fromTime method is then used to create a Date object from this value. The result will be the date '2024-08-13 06:23:35', which will be printed.



Other useful Haxe date functions

Function Description Example
Date.now() Returns the current date and time as a Date object. Date.now() returns 2024-08-28 12:34:56
Date.fromTime() Creates a Date object from the number of milliseconds since the Unix epoch. Date.fromTime(1589530245000) returns 2020-05-15 08:10:45
getTime() Returns the number of milliseconds since January 1, 1970 for a Date object. date.getTime() returns 1589530245000
Date.fromString() Parses a string representation of a date into a Date object. Date.fromString("2020-05-15 08:10:45") returns 2020-05-15 08:10:45
Date.toString() Returns a string representation of the date in ISO 8601 format. date.toString() returns 2020-05-15T08:10:45
Date.fromUnix() Parses a Unix timestamp (in seconds) into a Date object. Date.fromUnix(1589530245) returns 2020-05-15 08:10:45
DateTools.format() Formats a Date object into a custom string format. DateTools.format(date, "%Y-%m-%d %H:%M:%S") returns 2020-05-15 08:10:45
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