Showing posts with label PHP gatedate Function Tutorial. Show all posts
Showing posts with label PHP gatedate Function Tutorial. Show all posts

Sunday, April 29, 2012

PHP gatedate Function Tutorial


gatedate Function
The getdate() function returns an array that contains date ten elements with relevant information needed when formatting a date string:
      [seconds] - seconds
      [minutes] - minutes
      [hours] - hours
      [mday] - day of the month (numeric) 
      [wday] - day of the week (numeric) 
      [mon] - month 
      [year] - year
      [yday] - day of the year (numeric) 
      [weekday] - name of the weekday
      [month] - name of the month
Syntax
getdate(timestamp)
timestamp is optional.

Example: 1
<?php
print_r(getdate());
?>
Output
Array ( [seconds] => 51 [minutes] => 58 [hours] => 2 [mday] => 30 [wday] => 1 [mon] => 4 [year] => 2012 [yday] => 120 [weekday] => Monday [month] => April [0] => 1335769131 ) 

Example: 2
       <?php
       $today = getdate();
       $Month = $today['month'];
       $Day = $today['mday'];
       $Year = $today['year'];
       $Hour = $today['hours'];
       $Minutes = $today['minutes'];
       $Seconds = $today['seconds'];
       echo "Today's date is $Day $Month $Year"."<br>";
       echo "The time is now $Hour $Minutes $Seconds";
       ?>
Output
Today's date is 30 April 2012
The time is now 2 58 51