PHP uses getdate to get the current date time as an associative array method _php tips

Source: Internet
Author: User
Tags getdate

This example describes how PHP uses getdate to get the current date time as an associative array. Share to everyone for your reference. The specific analysis is as follows:

The PHP getdate function is used to get the current date and time, from the operating system or an associative array to a UNIX-style date integer.

The syntax format is as follows

Array getdate ();
Array getdate (integer $Time);

The parameters are as follows:
Arguments

$Time
The number of seconds since midnight before January 1, 1970. (UNIX style.)
Default
The default is the "Current date" and "Operating system."

The return value is a associative array containing:

Mon the month of the year as a number (1..12)
Mday the day of the month (1..31)
Year of the year (4 digits)
Hours the hour of the day (0..23)
Minutes the minutes of the hour (0..59)
Seconds the seconds of the minute (0..59)
Month the month of the year as a word (January. December)
Yday the Year (0..365)
Wday the day of the week as a number (0..6)
Weekday the day of the week as a word (Sunday. Saturday)
0 Seconds since midnight before January 1, 1970

Here is a sample usage:

<?php
$Now = getdate ();
foreach ($Now as $Key => $Value) {
 echo "$Key => $Value \ n";
}
? >

The output results are as follows:

Seconds =>
minutes => hours =>
7
mday =>
wday => 6
Mon
=> year => 2009
yday => 359
weekday => Saturday month =>
December
0 => 1261811699

I hope this article will help you with your PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.