Date problem

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


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";
		var d1 = Date;				// OK
		var d2 =;		// Error
		var response = "OK";		
		var json:String = haxe.Json.stringify({});
		if (callbackName != null) {
			json = callbackName + "(" + json + ")";

Compiled with:
-main Server
-php Program/PHP

Are you sure you posted the full sample?
I can’t reproduce it. And there’s no single isValid call in the whole standard library.

Make sure your code doesn’t clash with libs installed from PEAR. They have a toplevel Date class too.
Try building your project with -D or --php-prefix (Haxe 3) to put your Haxe code into it’s own package structure, then you should be safe.

Note: If you run a Haxe 3 project and use resources, you’ll have to manually put them into the correct subfolder.

1 Like

Wow, worked !