라이브러리

[PHP] IntlCalendar::after - 이 객체의 시간이 전달된 객체의 시간 이후인지 여부




IntlCalendar::after


PHP의 IntlCalendar 클래스는 국제 날짜 및 시간 관련 기능을 제공합니다. IntlCalendar::after 메서드는 두 날짜 사이의 관계를 확인하는 데 사용됩니다. 이 메서드는 현재 날짜 객체가 지정된 날짜 이후인지 여부를 boolean 값으로 반환합니다.

IntlCalendar::after 메서드의 사용 예제


#hostingforum.kr
php

// IntlCalendar 인스턴스 생성

$now = new DateTime();

$calendar = IntlCalendar::fromDateTime($now);



// 지정된 날짜

$targetDate = new DateTime('2024-03-16');



// IntlCalendar 인스턴스에 지정된 날짜 설정

$calendar->set($targetDate->format('Y'), $targetDate->format('m'), $targetDate->format('d'));



// IntlCalendar::after 메서드 사용

$isAfter = $calendar->after($now);



// 결과 출력

if ($isAfter) {

    echo "지정된 날짜는 현재 날짜 이후입니다.";

} else {

    echo "지정된 날짜는 현재 날짜 이전입니다.";

}



IntlCalendar::after 메서드의 사용 예제 (2)


#hostingforum.kr
php

// IntlCalendar 인스턴스 생성

$now = new DateTime();

$calendar = IntlCalendar::fromDateTime($now);



// 지정된 날짜

$targetDate = new DateTime('2022-01-01');



// IntlCalendar 인스턴스에 지정된 날짜 설정

$calendar->set($targetDate->format('Y'), $targetDate->format('m'), $targetDate->format('d'));



// IntlCalendar::after 메서드 사용

$isAfter = $calendar->after($now);



// 결과 출력

if ($isAfter) {

    echo "지정된 날짜는 현재 날짜 이후입니다.";

} else {

    echo "지정된 날짜는 현재 날짜 이전입니다.";

}



IntlCalendar::after 메서드의 사용 예제 (3)


#hostingforum.kr
php

// IntlCalendar 인스턴스 생성

$now = new DateTime();

$calendar = IntlCalendar::fromDateTime($now);



// 지정된 날짜

$targetDate = new DateTime('2024-03-16');



// IntlCalendar 인스턴스에 지정된 날짜 설정

$calendar->set($targetDate->format('Y'), $targetDate->format('m'), $targetDate->format('d'));



// IntlCalendar::after 메서드 사용

$isAfter = $calendar->after($now);



// 결과 출력

if ($isAfter) {

    echo "지정된 날짜는 현재 날짜 이후입니다.";

} else {

    echo "지정된 날짜는 현재 날짜 이전입니다.";

}



IntlCalendar::after 메서드는 두 날짜 사이의 관계를 확인하는 데 사용됩니다. 이 메서드는 현재 날짜 객체가 지정된 날짜 이후인지 여부를 boolean 값으로 반환합니다. 위의 예제에서는 IntlCalendar::after 메서드를 사용하여 지정된 날짜가 현재 날짜 이후인지 여부를 확인했습니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

  • 전체 10,077건 / 450 페이지

검색

게시물 검색