Публикации с тегом "????"

????????? ???? ?? MySQL ? PHP

??? ????????, ? MySQL ???? ??? ???????? ???? ?????? ??? ???????? ???: date ? datetime. ?????? ???????, ?? ????, ???????? ??????????? ????????? ??????? ? ????????? ?????? ???? ??????? ? ?????. ??? ?????????? ?? MySQL ?????? ?????? ???? ?? ???????? ?????? ?????????????? ????????? ????????:

2012-03-03
2012-03-03 12:00:00

?????? ? PHP ? ??????????? ???????? ?????? ? ?????? ???????????? ??? ?????????? ?????? ???? Unix timestamp, ?????????????? ?? ???? ????? ?????????? ?????? ????? "?????? ?????" (???????? ??????? ?????? 1970 ????) ? ??????? ????????.

????? ??? ?????? ???????? ???????? ?? ?????????????? ????? ???????? ????, ?????? ? ?.?. ? ???????? ?? ? PHP-??????? mktime, ?? ? ????????? ??????? ?????. ?????????? MySQL-??????? Unix_timestamp, ??????? ????????? ????????????? ???? ?? ??????? MySQL ? ?????? Unix timestamp ?? ????? ???????. ???????????? ????????? ???????:

SELECT created                 AS created_mysql,
       Unix_timestamp(created) AS created_unix
FROM   articles;

??????? ???? ?? PHP

???? ?????????? ????????, ??????? ????????? ???????????? ???? ? ??????????????? ???????? ? ????? ??????:

function rusdate($d, $format = 'j %MONTH% Y', $offset = 0)
{
    $montharr = array('??????', '???????', '?????', '??????', '???', '????', '????', '???????', '????????', '???????', '??????', '???????');
    $dayarr = array('???????????', '???????', '?????', '???????', '???????', '???????', '???????????');
 
    $d += 3600 * $offset;
 
    $sarr = array('/%MONTH%/i', '/%DAYWEEK%/i');
    $rarr = array( $montharr[date("m", $d) - 1], $dayarr[date("N", $d) - 1] );
 
    $format = preg_replace($sarr, $rarr, $format); 
    return date($format, $d);
}

?????? ???????? ?????-????, ?????? ?????? ????????? ????. ??? ????????? ????????? ?????????? PHP-??????? date(), ?????? ? ??????? ????? ???????? ??? ?????????????? ???????: