PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

How do you get an array of the date and time?


Sometimes you might find it useful to be able to access an array of details relating to the time and date.

To do this you use the handy getdate function, like this:

<?php
$date 
getdate();
echo 
$date['month'];//September
?>


There are a range of keys available to you in the associative array that results from calling getdate, for the full list check out the page on www.php.net - the most useful are year,month,mday,hours,minutes,seconds



More other PHP Questions

I have lots of if else logic - is there another option?
How do I check if a date entered exists?
How do I define a constant in PHP?
Can PHP create PDF files for me?
How do I add comments to my PHP script?