Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / PHP, Perl, Python [игнор отключен] [закрыт для гостей] / strtotime() и date() странно преобразуют даты / 4 сообщений из 4, страница 1 из 1
31.10.2013, 09:58
    #38447787
Uncle Roma
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
strtotime() и date() странно преобразуют даты
Есть такой простенький код.

Код: php
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
<?php
$ch1 = '26.12.10';
echo $ch1.'<br>';
echo date('Y-m-d H:i:s', strtotime($ch1));
echo '<br><br>';

$ch2 = '19.11.06';
echo $ch2.'<br>';
echo date('Y-m-d H:i:s', strtotime($ch2));
?>



Вот результат его работы:
26.12.10

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in D:\WebServers\home\localhost\www\syst\Ora2MySQL\date_bug.php on line 4

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in D:\WebServers\home\localhost\www\syst\Ora2MySQL\date_bug.php on line 4
2010-12-26 00:00:00

19.11.06

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in D:\WebServers\home\localhost\www\syst\Ora2MySQL\date_bug.php on line 9

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in D:\WebServers\home\localhost\www\syst\Ora2MySQL\date_bug.php on line 9
2013-10-31 19:11:06

Вопрос: почему 2010-й год конвертируется нормально, а 2006-й год превращается в 2013 ?
...
Рейтинг: 0 / 0
31.10.2013, 10:05
    #38447796
Uncle Roma
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
strtotime() и date() странно преобразуют даты
P.S. Предупреждения о таймзоне убрал, вставив строку
Код: php
1.
date_default_timezone_set("Europe/Moscow"); 



Но проблему с конвертацией даты это не решило.
...
Рейтинг: 0 / 0
31.10.2013, 11:46
    #38447996
strtotime() и date() странно преобразуют даты
...
Рейтинг: 0 / 0
31.10.2013, 12:36
    #38448155
Uncle Roma
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
strtotime() и date() странно преобразуют даты
как-то так...,
спасибо за ответ, разобрался.
...
Рейтинг: 0 / 0
Форумы / PHP, Perl, Python [игнор отключен] [закрыт для гостей] / strtotime() и date() странно преобразуют даты / 4 сообщений из 4, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]