Confusing about Date result

look at this js code

var date1= new Date(2021,7,1,0,0,0)             //[same as haxe target to js]( 
console.log(date1.getTime()) //1627747200-000    

const date2 = new Date('2021-07-01T00:00:00');

how to got the date2 result in haxe ?

There is Date.fromString but the formats it can take are different than js, so you’d have to do something like:

using StringTools;

class Test {
  static function main() {
    final date2 = Date.fromString("2021-07-01T00:00:00".replace("T", " "));

month in Date constructor is zero based (see Date - Haxe 4.2.1 API)