F
F
faragly2015-06-26 21:35:06
PHP
faragly, 2015-06-26 21:35:06

How to solve problems with Date and DateTime in 1C-Bitrix?

Hello! After it is not clear what update, in 14.5 everything was fine, the code

echo new \Bitrix\Main\Type\DateTime("16.08.2014 15:30:10");

stopped working, shows
[Bitrix\Main\ObjectException] 
Incorrect date/time: 16.08.2014 15:30:10 (500)
C:\OpenServer\domains\localhost\bitrix\modules\main\lib\type\datetime.php:47
#0: Bitrix\Main\Type\DateTime->__construct(string)
  C:\OpenServer\domains\localhost\test.php:30

If you simply display new \Bitrix\Main\Type\DateTime(), then the object will have the following content:
Bitrix\Main\Type\DateTime Object
(
    [value:protected] => DateTime Object
        (
            [date] => 2015-06-26 21:31:37.000000
            [timezone_type] => 3
            [timezone] => Europe/Moscow
        )

)

The first thing that caught my eye was the presence in [date] => 2015-06-26 21:31:37 .000000 of zeros after the dot. Previously, they were not ... It seems that all the problems are due to this. Do I have one? Or is it massive? How to solve a glitch?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2015-06-27
@opium

The default date format setting may have gone wrong,
set the format when creating an object

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question