In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "the method of converting dates in int format in php". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Add a time timestamp through "$lasTtime=time ();".
2. Use the "date (" Y-m-d ", $lastTime); method to convert it to a date format.
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 seconds / minute divided by 60c_time/60 and 5 to compare "the method of converting dates in int format in php". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.