Home  >  Article  >  Backend Development  >  Example of usage of php getdate function

Example of usage of php getdate function

WBOY
WBOYOriginal
2016-07-25 08:57:351300browse
  1. $a = getdate();
  2. printf('%s %d, %d',$a['month'],$a['mday'],$a[' year']);
  3. ?>
Copy code

2. getdate() uses the specified timestamp

  1. $a = getdate(163727100);
  2. printf('%s %d, %d',$a['month'],$a['mday'],$a ['year']);
  3. ?>
Copy code

3, getdate() to get the current date

  1. getdate() Get the current date -bbs.it-home.org
  2. $date_array = getdate();
  3. foreach ( $date_array as $key => $val ) {
  4. print "$key = $val
    ";
  5. }
  6. ?>

  7. print "Today's date: ";
  8. print $date_array['mon']."/".$date_array['mday']." /".$date_array['year'];
  9. ?>
  • Copy the code

    Attached, Correspondence between return values ​​of getdate() function

    Key Value secondsSeconds minutes Minutes hours Hours mday Day of the month wday Day of the week, numeric (Sunday is 0, Saturday is 6) mon Month, numeric year year, numeric (4 digits) yday Day of the year, numeric (e.g., 299) weekday Day of the week, textual, full (e.g., "Friday") month Month, textual, full (e.g., "January") 0 Seconds since epoch (what time( ) returns)


    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn