PHP
 Computer >> コンピューター >  >> プログラミング >> PHP

PHPのdate_default_timezone_get()関数


date_default_timezone_get()関数は、デフォルトのタイムゾーンを返します。

構文

date_default_timezone_get(void)

パラメータ

  • 無効 − NA

戻る

date_default_timezone_get()関数は文字列を返します。

以下は例です-

<?php
   echo "Old time zone is ". date_default_timezone_get();
   $timeZone = 'America/Costa_Rica';

   if( date_default_timezone_set( $timeZone) ){
      # Now get this time zone.
      echo "New time zone is ". date_default_timezone_get();
   }
?>

出力

以下は出力です-

Old time zone is UTC
New time zone is America/Costa_Rica

別の例を見てみましょう-

<?php
   echo date_default_timezone_get();
?>

出力

以下は出力です-

UTC

  1. PHPのfilectime()関数

    filectime()関数は、ファイルの最終変更時刻を返します。ファイルの最終変更時刻をUNIXタイムスタンプとして返​​し、失敗するとfalseを返します。 構文 filectime ( file_path ); パラメータ file_path- 最終変更時刻が検出されるファイルのパス。 戻る filectime()関数は、ファイルの最終変更時刻をUNIXタイムスタンプとして返​​し、失敗するとfalseを返します。 例 <?php    echo filectime("info.txt"); ?> 出力 193463225

  2. PHPのfileatime()関数

    fileatime()関数は、ファイルの最終アクセス時刻を返します。ファイルの最後にアクセスされた時刻をUNIXタイムスタンプとして返​​します。失敗するとfalseを返します。 構文 fileatime ( file_path ); パラメータ file_path- 最終アクセス時刻が検出されるファイルのパス。 戻る fileatime()関数は、ファイルの最後にアクセスされた時刻をUNIXタイムスタンプとして返​​します。失敗するとfalseを返します。 例 <?php    echo fileatime("new.txt");