Using Date on php results in error “Error Exception: Non-static method Date_TimeZone::isValid() should not be called statically”.
Haxe-version: 4.0.5
PHP (Strato): 7.3
Code
import php.Web;
import php.Lib;
import haxe.Serializer;
import haxe.Unserializer;
class Server {
// *******************
public function new() {}
// *************************************
public static function main() {
var callbackName = php.Web.getParams().get("callback");
var mimetype = "application/json";
if (callbackName != null) {
mimetype = "application/javascript";
}
Web.setHeader("Content-Type",mimetype);
Web.setHeader("Connection","close");
Web.flush();
var d1 = Date; // OK
var d2 = Date.now(); // Error
var response = "OK";
var json:String = haxe.Json.stringify({serializedResponse:Serializer.run(response)});
if (callbackName != null) {
json = callbackName + "(" + json + ")";
}
Web.setHeader("Content-Length",(""+json.length));
Lib.println(json);
Web.flush();
}
}
Compiled with:
-main Server
-debug
-php Program/PHP