<?php class time{ private $year;//年 private $month;//月 private $day;//天 private $hour;//小时 private $minute;//分钟 private $second;//秒 private $weekday;//星期 private $longDate;//完整的时间格式 private $diffTime;//两个时间的差值 //返回年份 time:时间格式为时间戳 2016-8-27 function getyear($time="",$type=""){ if($time==""){ $time=time(); } if($type==1){ return $this->year=date("y",$time); //返回两位的年份 16 }else{ return $this->year=date("Y",$time); //返回四位的年份 2016 } } //返回当前时间的月份 time:时间格式为时间戳 2016-8-27 function getmonth($time="",$type=""){ if($time==""){ $time=time(); }
A complete example of PHP time class, involving PHP's various operating techniques for obtaining and comparing dates, times, days, etc. It is very simple and practical. Friends who need it can refer to it to facilitate everyone to learn and experience PHP code.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article

13Dec2024
Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

19Oct2024
Using PHP's DateTime Class to Check if Time Is Between Two Time ValuesThis code snippet explores a solution to determining if a given time falls within a specified range, represented by a sunrise and sunset timeframe.Code:$current_time = "4:59 p

25Oct2024
Why Can't You Initialize a PHP Property to a Function?When attempting to initialize a PHP class property to a function during its declaration, a...

12Jul2016
PHP implements a complete instance of the Model base class based on mysqli, phpmysqlimodel base. PHP implements a complete example of the Model base class based on mysqli, phpmysqlimodel base This article describes an example of PHP implementing the Model base class based on mysqli. Share it with everyone for your reference, the details are as follows: DB.c

12Jul2016
PHP implements the generation of complete instances of MYSQL statement classes and mysql statements through parameters. A complete example of generating a MYSQL statement class through parameters in PHP, mysql statement. This example describes how to generate a MYSQL statement class through parameters in PHP. Share it with everyone for your reference, the details are as follows

28Oct2024
Suppression of Tensorflow Debugging OutputTensorflow prints extensive information about loaded libraries, found devices, and other debugging data...


Hot Tools

PHP library for dependency injection containers
PHP library for dependency injection containers

A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking

Small PHP library for optimizing images
Small PHP library for optimizing images
