PHP timestamp

 PHP timestamp generally refers to the UNIX timestamp. The Unix epoch is 00:00:00 on January 1, 1970. Get the PHP timestamp of a certain point in time, which represents the point in time and the Unix epoch. The time difference is usually measured in seconds. The way to get PHP timestamp is very simple. PHP has built-in functions to get timestamp. For example, time function and mktime are both very useful. timestamp Timestamp is a very useful technique used by PHP to calculate the time difference, and it has been used in early versions of PHP. It is also the basis of PHP. Below we use the time function and mktime as examples for your reference.


PHP timestamp Example of obtaining a timestamp 1. Using the time function
<?php
  echo'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; //Web page encoding
  echo'current Unix timestamp:'.time().'< br>'; //Current Unix timestamp
?>
Output result (for reference only, not the current time)
current Unix timestamp: 1412666448
PHP time is a very simple function used to calculate timestamp timestamp. It can be directly output without parameters. The current time is directly converted to timestamp, so that subsequent programs can easily obtain it. For detailed usage of the time function, please refer to " "PHP time function " detailed introduction.

PHP timestamp timestamp obtaining example two, using mktime
<?php
  echo'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; //Web page encoding
  echo mktime(date("H"),date("i "),date("s"),date("n"),date("j"),date("Y")).'<br>';
  echo mktime();
?>
Output result (for reference only, not the current time)
current Unix timestamp: 1412666448
current Unix timestamp: 1412666448
PHP mktime is also a function commonly used to process timestamps. In addition to obtaining the current timestamp directly, you can also obtain the timestamp of a specific time point through parameter settings, such as year, month, day, hour, minute, and second. Please refer to the description of PHP mktime " for detailed usage .

Post a Comment

0 Comments