Page 1 of 1

Incorrect time format when using PHP 8.3.x

Posted: Thu Jun 20, 2024 4:42 pm
by yinsw

PHPMaker v2024.12

I stored time in one of my MSSQL table field (datetime data type) with the value "1900-01-01 09:00:00". In PHPMaker I'm using the time picker and set the format as Date/Time and Date/Time format = Time (HHmm).

If I'm using PHP8.2.x, it displays correctly as 09:00, if I switch to PHP 8.3.8, it displays as 09:08.

There are breaking changes which is not compatible with the latest PHP 8.3.x? For now, I just switch back to latest stable version of PHP 8.2.x to use with PHPmaker


Re: Incorrect time format when using PHP 8.3.x

Posted: Thu Jun 20, 2024 4:49 pm
by arbei
  1. Did you mean the time picker cannot display the time correctly? Or the time in the input text box of the field does not display correctly?
  2. If you change the database value to "1970-01-01 09:00:00", can it be displayed correctly?
  3. If you change the data type to datetime2, can it be displayed correctly? According to Microsoft docs:
    Avoid using datetime for new work. Instead, use the time, date, datetime2, and datetimeoffset data types. These types align with the SQL Standard, and are more portable. time, datetime2 and datetimeoffset provide more seconds precision. datetimeoffset provides time zone support for globally deployed applications.

Re: Incorrect time format when using PHP 8.3.x

Posted: Thu Jun 20, 2024 5:03 pm
by yinsw
  1. No, the value in List Page, View Page and the time picker text box in Edit Page display the value incorrectly.
  2. Surprisingly, if I change the year to 1970 instead of 1900, the time display correctly. Please do take note that existing data in DB is inserted through Add Page generated by PHPMaker.
  3. Currently the data type is already datetime2.

Re: Incorrect time format when using PHP 8.3.x

Posted: Thu Jun 20, 2024 6:09 pm
by arbei

yinsw wrote:

I change the year to 1970 instead of 1900, the time display correctly.

Then it might be due to the fact that JavaScript cannot handle date earlier to 1970. But if there is the case, it does not explain why it works with PHP 8.2. Anyway, you may verify by disabling the datetime picker.

If possible you may also execute an UPDATE the field values from 1900 to 1970.