SPATIUM Mobile
주소복사
About Operating System Languages Tools Favorites Notice Visit TEST  
     Android (3)
     Linux (1)
     MacOS (1)
     OS (1)
     Solaris10 (15)
     Windows (1)
     Windows Server (2)
     Windows XP (3)
   ID  
   Password  
  |  
  Location United States
  IP Address 18.118.184.237
2024. 04
123456
78910111213
141516171819
20
21222324252627
282930
Category  Languages, PHP
Writer 김태우 Date 2011-09-07 15:18:20 Visit 8147
PHP 날짜 함수

 

테스트 일 : 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"));

 

Tags  php, PHP 날짜함수, date
  Relation Articles
[Languages-ASP] ASP 날짜함수 (2012-05-31 11:34:19)
[Languages-JavaScript] 날짜 비교 (2012-01-19 18:33:30)
[Languages-PHP] PHP 기본연산자 (2011-12-14 18:30:50)
[Languages-PHP] PHP 문자열함수(String Function) (2011-11-16 10:03:03)
[Languages-PHP] php 간단 mysql 접속 및 select 쿼리 실행 (2011-09-29 15:11:43)
[Languages-PHP] PHP 날짜 함수 (2011-09-07 15:18:20)
[Languages-PHP] Input 태그 숫자제한, Javascript (2011-07-28 15:25:33)
  Your Opinion
Member ID
150 letters
Copyright (C) SPATIUM. All rights reserved.
[SPATIUM]WebMaster Mail