Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change time in php int

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "how php int turns time". In daily operation, I believe many people have doubts about how php int turns time. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how php int turns time". Next, please follow the editor to study!

Php int to time method: 1, add a time timest 2, through the "date (" Y-m-d ", $lastTime);" method to convert the number of int type into the time format.

This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer

How does php int change the time?

Php converts int types to time types

I encountered the problem of timestamp conversion in this project.

The timestamp of the database design is in int format, all of which require some conversion.

$lasTtime=time (); / / this adds a time timestamp

This timestamp outputs the current time and converts it to int: 1558321414 / / this is the timestamp when I wrote this.

You can use it when you extract it.

$time=date ("Y-m-d", $lastTime); / / date is a function that converts to the format you specify

The timestamp will become: 2019-05-20 11:03:34 / / this is the timestamp when I wrote this.

If you still want to convert 2019-05-20 11:03:34 to int format

$lastTime=strtotime ($time); / / $time is the variable you want to convert

It will eventually become: 1558321414 / / this is the timestamp when I wrote this.

If there is a time difference, you can use date_default_timezone_set ("PRC"); solve the 8-hour jet lag problem

Y-m-d H:i:s'// this is the defined time format / / what is needed / / s is s, minute is I, hour is H, day is d, month is m, and year is Yecho date ('iPrecious timekeeper); / / if you want to calculate with the current time, you don't have to convert it to time type $time_str = 1313994356 access centering time = time ()-$time_str What c_time gets is second / minute divided by 60c_time/60 and 5 to compare this, the study on "how php int turns time" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report