In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "php how to query sql according to time". 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!
Php query sql according to time: 1. Convert database time into timestamp through strtotime; 2. Use "select * from `ecs_order_ info` where add_time between..." Statement to select and query the SQL data.
This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer
How does php query sql based on time?
The following is a timestamp query. If the database time shows 2011-04-05, there is no need to use the strtotime timestamp conversion function:
$timea = strtotime ($_ POST ['timea']); $timeb = strtotime ($_ POST [' timeb']); $sq2= "select * from `ecs_order_ info`where add_time between'$timea' and'$timeb' and `quintuan` ='$dangqian' order by `order_ id` DESC limit 50"; $sql = mysql_query ($sq2)
Extended data
Done in php
1. The function used to convert UNIX timestamp to date: date ()
General form: date ('Y-m-d Hizuirig slots, 1156219870)
2. Convert date to UNIX timestamp with function: strtotime ()
General form: strtotime ('2010-03-24 08 1542')
Done in MySQL
This method is converted in the MySQL query statement, the advantage is that it does not occupy the parsing time of the PHP parser, the speed is fast, the disadvantage is that it can only be used in the database query, there are limitations.
1. The function used to convert UNIX timestamp to date: FROM_UNIXTIME ()
General form: select FROM_UNIXTIME (1156219870)
2. Convert date to UNIX timestamp with function: UNIX_TIMESTAMP ()
General form: Select UNIX_TIMESTAMP ('2006-11-04 12 2300')
For example: the number of records on the day of mysql query:
$sql= "select * from message Where DATE_FORMAT (FROM_UNIXTIME (chattime),'% Ymuri% mmury% d') = DATE_FORMAT (NOW (),'% Ymuri% mmi% d') order by id desc".
This is the end of the content of "php how to query sql according to time". 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.