ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  chartTime2 delayed time
Posted by Marko on Aug-30-2023 20:50
Hello.

I'm using PHP chartDirector on windows IIS + php 7.1.25 + CD version 6000003 (100663299)
Calling chartTime2 results in 3h delay:

  echo  chartTime2(strtotime('2023-08-30 14:00')); // returns 63829011600

When I test on my local machine everything seems ok: IIS + php 7.4.13 CD version 6030000 (100859904)

Is this version related?
Is it related to system configuration? I don't know where to look, please help.

Thanks, Marko.

  Re: chartTime2 delayed time
Posted by Peter Kwan on Aug-31-2023 00:28
Hi Marko,

The issue may be due to inconsistent time zones. For example, the time zone configured in PHP may be different from the time zone of the Linux OS. ChartDirector follows the OS time zone. The PHP code probably uses the PHP time zone. If there are other components (eg. database), they may have their own time zone configuration too.

No matter what are the time zone configurations, a UNIX timestamp generated by PHP will be always be understood by PHP itself. So one method is to use PHP to determine the time components (yyyy-mm-dd hh:nn:ss), and use these components to set up chartTime. It is like:

$t = strtotime('2023-08-30 14:00');
$ymdhns = localtime($t);

$ct = chartTime($ymdhns["tm_year"] + 1900, $ymdhns["tm_mon"] + 1, $ymdhns["tm_day"], $ymdhns["tm_hour"], $ymdhns["tm_min"], $ymdhns["tm_sec"]);

If the UNIX timestamp comes from a database, the most reliable method is not to return the UNIX timestamp. Instead, the SQL query can ask the database to return the time components (yyyy, mm, dd, hh, nn, ss) directly, and use them to create chartTime.

Regards
Peter Kwan