PHP Gets the current timestamp method

Source: Internet
Author: User
Tags echo date
Brief introduction

PHP to get time is a very easy thing, the following small part on the simple to share some of the experience of the individual learning PHP it;

Operation method

1. Get the current Time method date ()

Quite simply, this is the way to get the time, in the format: Date ($format, $timestamp), format, timestamp timestamp--can be filled in parameters.
2. Get timestamp method Time (), Strtotime ()
Both of these methods can obtain the UNIX timestamp in PHP, Time () is directly obtained, Strtotime ($time, $now) to the time format to timestamp, $time is required. Clear this, want to know more, please continue to look down.

3. Date ($format) usage
Like what:
echo Date (' y-m-d '), Output: 2012-03-22
echo Date (' y-m-d h:i:s '), Output: 2012-03-22 23:00:00
echo Date (' y-m-d ', Time ()), Output: 2012-03-22 23:00:00 (results above, just one more timestamp parameter) (method of timestamp conversion to date format)
echo Date (' Y '). ' Year '. Date (' m '). ' Month '. Date (' d '). ' Day ', output: March 22, 2012

PHP Gets the current timestamp method

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.