Как получить дату в таком формате (php)?

Здравствуйте, нужно отформатировать дату для CRM Redtail.
CRM требует в таком формате
Date(-62135568000000-0800)
unix time stamp не проходит.
  • Вопрос задан
  • 171 просмотр
Решения вопроса 1
@bkosun
Значения DateTime отображаются в виде строк JSON в виде "/Date (700000 +0500)/", где первое число (700000 в приведенном примере) - это количество миллисекунд в часовом поясе GMT, регулярное (не дневная летняя экономия ) время с полуночи, 1 января 1970 года. Число может быть отрицательным для представления более ранних времен. Часть, которая состоит из "+0500" в примере, является необязательной и указывает, что время относится к локальному виду, то есть должно быть преобразовано в локальный часовой пояс при десериализации. Если он отсутствует, время десериализуется как Utc.


DateTime Wire Format

DateTime values appear as JSON strings in the form of "/Date(700000+0500)/", where the first number (700000 in the example provided) is the number of milliseconds in the GMT time zone, regular (non-daylight savings) time since midnight, January 1, 1970. The number may be negative to represent earlier times. The part that consists of "+0500" in the example is optional and indicates that the time is of the Local kind - that is, should be converted to the local time zone on deserialization. If it is absent, the time is deserialized as Utc. The actual number ("0500" in this example) and its sign (+ or -) are ignored.

When serializing DateTime, Local and Unspecified times are written with an offset, and Utc is written without.

The ASP.NET AJAX client JavaScript code automatically converts such strings into JavaScript DateTime instances. If there are other strings that have a similar form that are not of type DateTime in .NET, they are converted as well.

The conversion only takes place if the "/" characters are escaped (that is, the JSON looks like "\/Date(700000+0500)\/"), and for this reason WCF's JSON encoder (enabled by the WebHttpBinding) always escapes the "/" character.


https://docs.microsoft.com/en-us/dotnet/framework/...

Простой пример (текущая дата):
echo time() * 1000 . date('O'); // 1533822186000+0300

O - Разница с временем по Гринвичу, в часах

php.net/manual/ru/function.date.php
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
19 апр. 2024, в 20:43
20000 руб./за проект
19 апр. 2024, в 20:11
500 руб./за проект