Available on all platforms
The DateTools class contains some extra functionalities for handling Date instances and timestamps.
In the context of Haxe dates, a timestamp is defined as the number of milliseconds elapsed since 1st January 1970.
staticinlinedays(n:Float):FloatConverts a number of days to a timestamp.
staticinlinedelta(d:Date, t:Float):DateReturns the result of adding timestamp t to Date d.
This is a convenience function for calling Date.fromTime(d.getTime() + t).
staticformat(d:Date, f:String):StringFormat the date d according to the format f. The format is compatible with the strftime standard format, except that there is no support in Flash and JS for day and months names (due to lack of proper internationalization API). On Haxe/Neko/Windows, some formats are not supported.
var t = DateTools.format(Date.now(), "%Y-%m-%d_%H:%M:%S");
// 2016-07-08_14:44:05
var t = DateTools.format(Date.now(), "%r");
// 02:44:05 PM
var t = DateTools.format(Date.now(), "%T");
// 14:44:05
var t = DateTools.format(Date.now(), "%F");
// 2016-07-08
staticgetMonthDays(d:Date):IntReturns the number of days in the month of Date d.
This method handles leap years.
staticinlinehours(n:Float):FloatConverts a number of hours to a timestamp.
staticmake(o:{seconds:Int, ms:Float, minutes:Int, hours:Int, days:Int}):FloatBuild a date-time from several components
staticmakeUtc(year:Int, month:Int, day:Int, hour:Int, min:Int, sec:Int):FloatAvailable on php, js, cpp, python, flash
Retrieve Unix timestamp value from Date components. Takes same argument sequence as the Date constructor.
staticinlineminutes(n:Float):FloatConverts a number of minutes to a timestamp.
staticparse(t:Float):{seconds:Int, ms:Float, minutes:Int, hours:Int, days:Int}Separate a date-time into several components
staticinlineseconds(n:Float):FloatConverts a number of seconds to a timestamp.
© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/DateTools.html