W3cubDocs

/Haxe

Date

no package

@:coreApi Available on all platforms

The Date class provides a basic structure for date and time related information. Date instances can be created by

There are some extra functions available in the DateTools class.

In the context of Haxe dates, a timestamp is defined as the number of milliseconds elapsed since 1st January 1970.

Constructor

@:has_untyped new (year:Int, month:Int, day:Int, hour:Int, min:Int, sec:Int)

Creates a new date object from the given arguments.

The behaviour of a Date instance is only consistent across platforms if the the arguments describe a valid date.

  • month: 0 to 11
  • day: 1 to 31
  • hour: 0 to 23
  • min: 0 to 59
  • sec: 0 to 59

Methods

@:has_untyped getDate ():Int

Returns the day of this Date (1-31 range).

@:has_untyped getDay ():Int

Returns the day of the week of this Date (0-6 range) where 0 is Sunday.

@:has_untyped getFullYear ():Int

Returns the full year of this Date (4-digits).

@:has_untyped getHours ():Int

Returns the hours of this Date (0-23 range).

@:has_untyped getMinutes ():Int

Returns the minutes of this Date (0-59 range).

@:has_untyped getMonth ():Int

Returns the month of this Date (0-11 range).

@:has_untyped getSeconds ():Int

Returns the seconds of this Date (0-59 range).

getTime ():Float

Returns the timestamp (in milliseconds) of the date. It might only have a per-second precision depending on the platforms.

@:has_untyped toString ():String

Returns a string representation of this Date, by using the standard format [YYYY-MM-DD HH:MM:SS]. See DateTools.format for other formating rules.

Static methods

static fromString (s:String):Date

Returns a Date from a formated string s, with the following accepted formats:

  • "YYYY-MM-DD hh:mm:ss"
  • "YYYY-MM-DD"
  • "hh:mm:ss"

The first two formats are expressed in local time, the third in UTC Epoch.

static fromTime (t:Float):Date

Returns a Date from timestamp t.

@:has_untyped static now ():Date

Returns a Date representing the current local time.

© 2005–2018 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/Date.html