메뉴 건너뛰기

프로그램언어

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"));


  1. PHP 네이버블로그 원격 글쓰기 API 소스

  2. No Image 07Mar
    by
    2017/03/07 Views 17004 

    php 내장함수

  3. No Image 07Mar
    by
    2017/03/07 Views 18629 

    PHP 날짜/시간 정리

  4. No Image 06Mar
    by
    2017/03/06 Views 16707 

    PHP 날짜, 시간 관련 함수. date(), mktime()

  5. No Image 13Apr
    by 조쉬
    2017/04/13 Views 17673 

    PHP 날짜 함수

  6. php 간단 심플한 달력만들기

  7. PHP 가변변수 $$

  8. No Image 12Jan
    by
    2023/01/12 Views 251 

    PHP ZIP 압축파일 만들기

  9. PHP XML 문서파싱 (SAX 방식 , DOM 방식)

  10. No Image 12Jan
    by
    2023/01/12 Views 234 

    php www 붙이기

  11. PHP switch 문

  12. No Image 12Jan
    by
    2023/01/12 Views 197 

    PHP str_replace php 문자열치환

  13. No Image 27Oct
    by
    2018/10/27 Views 3536 

    PHP split()와 explode()의 차이점

  14. No Image 12Jan
    by
    2023/01/12 Views 220 

    PHP SimpleHtmlDom Parser로 HTML 파싱하기

  15. No Image 26Mar
    by
    2021/03/26 Views 308 

    PHP Notice: Use of undefined constant ... assumed ... 오류

  16. No Image 22Dec
    by
    2016/12/22 Views 19972 

    PHP Mcrypt 라이브러리를 활용한 암호화 시스템

  17. No Image 19Feb
    by
    2019/02/19 Views 2183 

    PHP http 를 https 로 전환(redirect), http->https

  18. No Image 12Jan
    by
    2023/01/12 Views 236 

    PHP http -> https 로 전환

  19. No Image 06Mar
    by
    2017/03/06 Views 18266 

    PHP EXCEL export시 시트 이름 지정하여 여러 시트에 데이터 쓰기

  20. PHP error 메시지 출력

Board Pagination Prev 1 ... 8 9 10 11 12 13 14 15 16 17 Next
/ 17

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved