메뉴 건너뛰기

프로그램언어

2017.04.13 18:27

PHP 날짜 함수

조회 수 17673 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
테스트 일 : 2011년 9월 7일

형식 : string date(string $format [, int $timestamp] )
  format parameters
    d => 01 to 31
    D => Mon through Sun
    w => 0(sunday) through 6(saturday)
    z => 0 through 365
    m => 01 through 12 (month)
    M => Jan through Dec
    t => 28 through 31 ( last day of month , 달 마지막 날 )
    Y => 1999 or 2011
    h => 01 through 12 (12 hour)
    H => 00 through 23 (24 hour)
    i => 00 to 59 (minutes)
    s => 00 through 59 (seconds)

오늘출력
echo date("Ymd");     출력->       20110907

오늘로 부터 3일 후
echo date("Y-m-d", strtotime("+3 day"));      출력->       2011-09-10

오늘로 부터 3일 전
echo date("Y-m-d", strtotime("-3 day"));      출력->       2011-09-04

오늘로 부터 일주일 전
echo date("Y-m-d", strtotime("-1 week"));      출력->       2011-08-31

유닉스 timestamp 값을 리턴
echo strtotime("now");      출력->      1315389514

특정일을 구하기
$oneweekbefore = strtotime("-1 week");
echo date("Y-m-d", strtotime("7 day", $oneweekbefore));      출력->       2011-09-07

특정일 구하기2-이번달 마지막날
mktime(시,분,초,월,일,년도)
echo date('t', mktime(0,0,0,9,7,2011);      출력->       30

이번주 월요일 구하기
$now1 = date("w");
$m = $now1-1;
echo date("Y-m-d", strtotime("-$m day"));


List of Articles
번호 제목 날짜 조회 수
340 리다이렉션(페이지 이동)의 3가지 방법, location.href 2017.03.07 40127
339 [PHP] 게시판 글쓰기와 이미지 파일 DB 저장 및 불러오기 예제 2017.02.19 35882
338 $_SERVER 환경변수 2016.09.21 33237
337 PHP에서 PDF파일 생성하기 2014.02.27 32777
336 PHP에서 자바스크립트 값 가져오기 2014.02.27 31635
335 Class를 이용한 DB Connection 소스 (Oracle, MyS 2014.02.27 30503
334 htmlentities <-> html_entity_decode (엔티티 2014.04.12 30384
333 무조건 알아야 할 PHP 속도 테스트 14 가지 2014.02.27 30280
332 PHP로 Excel 파일 만들기... 2014.02.27 30257
331 Text를 GD 이미지로 뿌리기 2014.02.27 29811
330 php 엑셀 다운로드 구현 2017.03.07 29782
329 글내용 이미지 리사이징 2014.02.27 29446
328 쿠키변수받기 2014.02.27 29211
327 Record Drag/Drop Position 2014.02.27 29201
326 간단한 PHP 파일 업로드, 다운로드 구현 2017.03.06 28547
325 DB상의 많은 파일을 한꺼번에 다운받기 2014.02.27 28332
324 GD를 이용한 스팸성 게시물 차단을 위한 보안 단어 입력 예제 2014.02.27 26945
323 주간날짜 뽑아오기 2014.02.27 26731
322 전화번호에 하이픈(-) 넣기 2015.04.14 26622
321 PHP 변수전달 GET, POST 2015.04.14 26564
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved