Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

PHP Function getdate()

<?php
   $today = getdate();
   print_r($today);
?>

Function date()

<?php
   date_default_timezone_set('UTC');
   
   echo date("l");
   echo "<br />";
   
   echo date('l dS \of F Y h:i:s A');
   echo "<br />";
   
?> 

Function date_timezone_set()

<?php
   $dateSrc = '2007-04-19 12:50 GMT';
   $dateTime = date_create( $dateSrc);
   $DateTimeZone = timezone_open ( 'America/Chicago' );
   date_timezone_set( $dateTime, $DateTimeZone );
   $NewDateTimeZone = date_timezone_get($dateTime);
   
   echo 'New timeZone is '. timezone_name_get($NewDateTimeZone);
   echo "\n";

   # Using second function.
   $dateTime = new DateTime($dateSrc);
   $DateTimeZone = timezone_open ( 'America/Chicago' );
   $dateTime->setTimezone( $DateTimeZone );
   $NewDateTimeZone = $dateTime->getTimezone ();
   
   echo 'New timeZone is '. timezone_name_get ($NewDateTimeZone);
?> 

Function getdate()

<?php
   $today = getdate();
   print_r($today);
?>

Function date()

<?php
   date_default_timezone_set('UTC');
   
   echo date("l");
   echo "<br />";
   
   echo date('l dS \of F Y h:i:s A');
   echo "<br />";
   
?> 

PHP Function date_timezone_get()

<?php
   $dateSrc = '2007-04-19 12:50 GMT';
   $dateTime = date_create( $dateSrc);;
   $DateTimeZone = date_timezone_get ( $dateTime );
   
   echo 'Return timeZone is '. timezone_name_get ($DateTimeZone);
   echo "\n";

   # Using second function.
   $dateTime = new DateTime($dateSrc);
   $DateTimeZone = $dateTime->getTimezone ();
   
   echo 'Return timeZone is '. timezone_name_get ($DateTimeZone);
?> 

PHP Function date_time_set()

<?php
   $dateSrc = '2007-04-19 12:50 GMT';
   $dateTime = date_create( $dateSrc);;
   $retval = date_time_set( $dateTime, 20, 40, 10);
   
   echo 'DateTime::format(): '.$dateTime->format('Y:M:D:H:i:s');
   echo "\n";

   # Using second function.
   $dateTime = new DateTime($dateSrc);
   $retval = $dateTime->setTime(20, 56,6);
   
   echo 'DateTime::format(): '.$dateTime->format('Y:M:D:H:i:s');
?>

PHP Function date_sunset()

<?php
   echo("Date: " . date("D M d Y") . "<br />");
   echo("Sunrise time: ");
   echo(date_sunset(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));
?> 

PHP Function date_sunrise()

<?php
   echo("Date: " . date("D M d Y") . "<br />");
   echo("Sunrise time: ");
   echo(date_sunrise(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));
?> 

Function date_sun_info()

<?php
   $sun_info = date_sun_info(strtotime("2017-07-12"), 31.7667, 35.2333);
   
   foreach ($sun_info as $key => $val) {
      echo "$key: " . date("H:i:s", $val) . "\n";
   }
?> 

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.