라이브러리

[PHP] IntlTimeZone::getDSTSavings - 로컬 벽시계 시간을 얻기 위해 로컬 표준 시간에 추가할 시간 양을 가져옵니다.


IntlTimeZone::getDSTSavings는 PHP의 IntlTimeZone 클래스의 메서드입니다. 이 메서드는 지정된 시간대에서 DST(일광 절약 시간) 적용 시각에 대한 보상을 반환합니다.

IntlTimeZone::getDSTSavings 사용법


IntlTimeZone::getDSTSavings 메서드는 두 개의 매개변수를 받습니다.

* `timezone`: 시간대 코드 (예: 'Asia/Seoul')
* `date`: 날짜 (예: 2022-01-01 00:00:00)

다음은 IntlTimeZone::getDSTSavings 메서드를 사용하는 예제입니다.

예제 1: DST 보상 계산


#hostingforum.kr
php

<?php



// 시간대 코드

$timezone = 'Asia/Seoul';



// 날짜

$date = new DateTime('2022-06-01 00:00:00', new DateTimeZone($timezone));



// DST 보상 계산

$dstsavings = IntlTimeZone::getDSTSavings($timezone, $date);



// 결과 출력

echo "DST 보상: $dstsavings 초
";



?>



예제 2: DST 보상 계산 (날짜가 없는 경우)


#hostingforum.kr
php

<?php



// 시간대 코드

$timezone = 'Asia/Seoul';



// 날짜가 없는 경우

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



// DST 보상 계산

$dstsavings = IntlTimeZone::getDSTSavings($timezone, $date);



// 결과 출력

echo "DST 보상: $dstsavings 초
";



?>



예제 3: DST 보상 계산 (날짜가 없는 경우, 시간대가 없는 경우)


#hostingforum.kr
php

<?php



// 시간대 코드가 없는 경우

$timezone = 'Unknown';



// 날짜가 없는 경우

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



// DST 보상 계산

$dstsavings = IntlTimeZone::getDSTSavings($timezone, $date);



// 결과 출력

echo "DST 보상: $dstsavings 초
";



?>



IntlTimeZone::getDSTSavings 메서드는 지정된 시간대에서 DST 적용 시각에 대한 보상을 반환합니다. DST 보상은 시간대에서 DST가 적용되는 동안 시간이 얼마나 앞당겨졌는지에 대한 정보를 제공합니다. 예제를 통해 IntlTimeZone::getDSTSavings 메서드를 사용하는 방법을 살펴보았습니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

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

검색

게시물 검색