PHP - Php Opening Hours
Similar Tutorialsin my MySql database i have a field "created_at" = now() for ex: 2011-05-23 11:47:28 i need to add two hours to that so i have 2011-05-23 13:47:28 how will i do this please? i have this so far but it is not correct: $currentTime = time($msg->getCreatedAt()); $timeAfterOneHour = $currentTime+60*60; $date=date("Y-m-d H:i:s",$timeAfterOneHour); please help thank you I am trying to make a function that is customizable to delete a query from a database. Here's the function. function checkHashs($hours) { if($getHashs = mysql_query('SELECT * FROM `hash_codes`')) { $dateQ = mysql_query('SELECT MAX(addedon) AS lastVoteDate FROM `hash_codes`') or die(mysql_error()); $getDate = mysql_fetch_assoc($dateQ); $diffrence = time() - strtotime($getDate['lastVoteDate']); echo $diffrence / 60 / 60; if (($diffrence / 60 / 60) >= $hours) { mysql_query('DELETE FROM `hash_codes` WHERE `addedon` = '. ($diffrence / 60 / 60) >= $hours .'') or die(mysql_error()); } } } And I am trying to call it by checkHashs(24); What I am trying to do is make it so when that function is ran it will delete all oh the guerys that have the `addedon` row over X hours(24 hours in this case). Any ideas? Im using $time = date('Y-m-d H:i:s'); How can I make a new variable that adds 4 hours on the $time output. Hi, I have a row In mysql data base called time and the content is filled with the time function time (); I want to know is there a way to achieve this I want the entire column deleted if it has been 24 hours since the time row was filled. I want this to happen automatically I don't really know how to achieve this so any help would be much appreciated thanks. Hello I am trying to do a cronjob to check if a user has been online within the past 24 hours. I have a column with "last_login" with this format: "1337593284". How can I do a simple if (last_login+24hours< servertime) { do something... Hey Guys. I am writing a function that will output to the user if a store is open or not.
I wrote a fucntions named is_store_open() with a variable called $day which will have the current day of the week assigned to it.
Lets say it is Saturday. it finds the case for "Saturday" and checks the opening time and closing time for Saturday.
The problem that I am facing, is when the store is open past midnight on Saturday. It then won't check the case for saturday.
Instead will check the case for Sunday. Which is not what I want, becuase it will show the store as closed when its open still open on "Saturday"
I wrote a function below that checks to see if the previous day closing hours are greater then the current time. If its true then return true and I guess that should fix the problem.
But when I wrote that it would give me an error saying that $saturday_close is undefined. I'm guessing its becuase its in a switch satement, and it does not equal to that day.
I'm a little bit confused on how to set this up. If anyone has a suggestion I would really apprecaite your help. Thanks!
function is_store_open(){ $set_time = strtotime("tomorrow"); // Lets just sat its Sunday for testing purposes $day = date("l", $set_time); $time_now = mktime("00", "00", "00"); // Now lets say the time now is 12:00am switch ($day) { case "Saturday": $open = "11:00"; $saturday_close = "1:00"; break; case "Sunday"; if($saturday_close > $time_now ){//If the $monday_close hours are greater then the current time return false the store is still open return true; } else { $open = "2:00"; $close = "22:00"; } break; } }// End of function if(is_store_open()) { echo "Oh no! There is still a glitch in the system the store needs to remain open"; } else { echo "The store is still open on Saturday"; } It was suppose to be my day off but here I set in front of the computer trying to figure out some code. I can not get my code to send me the information that is inputted into the fields. The style is what I want but most importantly it has got to work. I'm going to put the PHP code and the HTML code. If you need the CSS code I can post that. I'm not sure if you guys need that though. Hopefully someone out there can help me out. I know it might be a very simple error causing me tons of problems. I just can't figure it out. I'm novice at this stuff. PHP CODE & HTML CODE: <?php if ($_POST["email"]<>'') { $ToEmail = 'Justin@fullloop.net'; $emailSubject = 'contact'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; $MESSAGE_BODY = "Phone: ".$_POST["phone"]."<br>"; $MESSAGE_BODY .= "Your Email: ".$_POST["email"]."<br>"; $MESSAGE_BODY .= "Your Message: ".nl2br($_POST["comment"])."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?> <html> <body> <?php echo $_POST["name"]; ?>,<br /> Thank you for contacting Full Loop Inspections. We take great pride in our services and we are grateful you are considering us to complete your inspection. An inspector will contact you at <?php echo $_POST["phone"]; ?> or email you at <?php echo $_POST["email"]; ?> . </body> </html> <?php } else { ?> <form id="contacts-form" method="post" action="contact.php"> <fieldset> <div class="field"> <label>Your Name:</label> <input type="text" value="" name="name"/> </div> <div class="field"> <label>Your Phone:</label> <input type="text" value="" name="phone"/> </div> <div class="field"> <label>Your E-mail:</label> <input type="text" value="" name="text"/> </div> <div class="field"> <label>Your Message:</label> <textarea cols="1" rows="1"></textarea> </div> <div class="wrapper"><a href="contact-us.html" onClick="document.getElementById('contacts-form').submit()" class="link1"><em><b>SUBMIT</b></em></a></div> </fieldset> </form> <?php }; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head profile="http://www.w3.org/2005/10/profile"> <link rel="icon" type="image/gif" href="images/favicon.gif" /> <head> <title>Full Loop Inspections | Columbus Ohio #1 Home Inspector | Home Inspectors | Commercial | Mold | Grove City </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="Certified inspectors performing commercial and home inspections in Columbus, Grove City, Hilliard, Gahanna and surrounding areas" /> <meta name="keywords" content="Columbus home inspectors, Grove City Inspectors, Home Inspections, Home Inspector" /> <meta name="author" content="Full Loop Inspections | Home | Commercial | Mold | Radon | Mold Inspectors - http://www.fullloop.net" /> <link href="style.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script src="js/cufon-yui.js" type="text/javascript"></script> <script src="js/cufon-replace.js" type="text/javascript"></script> <script src="js/Myriad_Pro_400.font.js" type="text/javascript"></script> <script src="js/Myriad_Pro_600.font.js" type="text/javascript"></script> <script src="js/NewsGoth_BT_400.font.js" type="text/javascript"></script> <script src="js/NewsGoth_BT_700.font.js" type="text/javascript"></script> <script src="js/NewsGoth_Dm_BT_400.font.js" type="text/javascript"></script> <script src="js/script.js" type="text/javascript"></script> <!--[if lt IE 7]> <script type="text/javascript" src="js/ie_png.js"></script> <script type="text/javascript"> ie_png.fix('.png, #header .row-2 ul li a, .extra img, #search-form a, #search-form a em, #login-form .field1 a, #login-form .field1 a em, #login-form .field1 a b'); </script> <link href="ie6.css" rel="stylesheet" type="text/css" /> <![endif]--> <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-24965394-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();</script> </head> <body id="page5"> <div id="main"> <!-- HEADER --> <div id="header"> <div class="row-1"> <div class="fleft"><a href="home.html"><img src="images/logo.png" alt="full-loop-inspections" /></a></div> <div class="fright"> <div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=146395285448812&xfbml=1"></script><fb:like href="http://www.facebook.com/pages/Full-Loop-Inspections/237677882939676" send="true" layout="button_count" width="150" show_faces="true" action="like" font=""></fb:like> <g:plusone size="small"></g:plusone> <ul> <li><a href="home.html"><img src="images/icon1.gif" alt="home-inspections" /></a></li> <li><a href="contact-us.html"><img src="images/icon2-act.gif" alt="contact-a-home-inspector" /></a></li> <li><a href="home-inspectors-service-area.html"><img src="images/icon3.gif" alt="home-inspectors-sitemap" /></a></li> </ul> </div> </div> <div class="row-2"> <div class="left"> <ul> <li><a href="home.html"><span>home</span></a></li> <li><a href="inspection-services.html"><span>inspection services</span></a></li> <li><a href="payments.html"><span>Make Payments</span></a></li> <li><a href="contact-us.html" class="active"><span>contact</span></a></li> <li class="last"><a href="home-inspectors-service-area.html"><span>Service Area</span></a></li> </ul> </div> </div> <div class="row-3"> <div class="inside"> <h2>Columbus Ohio<b>Inspections</b></h2> <p>Full Loop Inspections services Columbus Ohio and surrounding cities. Franklin, Madison, Union, Delaware, Licking, Pickaway and Fairfield counties. Contact us today to set an Inspection appointment. </p> </div> </div> <div class="extra"><img src="images/header-img.png" alt="Columbus-Ohio-Inspectors" /></div> </div> <!-- CONTENT --> <div id="content"><div class="inner_copy">More <a href="http://www.templatemonster.com/">Website Templates</a> at TemplateMonster.com!</div> <div class="box"> <div class="border-bot"> <div class="right-bot-corner"> <div class="left-bot-corner"> <div class="inner"> <div class="box1 alt"> <div class="inner"> <h4><b>Our</b> Contacts</h4> <div class="address"> <p><b>Inspector:</b> Justin Ashley<br /> <b>Telephone:</b>614-256-6505<br /> <b>Address:</b>4690 Helmsbridge Ct<br /> <b>City:</b>Grove City, OH 43123<br /> <b>e-mail:</b><a href="mailto:Justin@Fullloop.net?subject=Online Inspection Referral">Justin@Fullloop.net</a></p> </div> <p class="p0 extra-wrap"><br /> <span class="img-box1"><img src="images/InterNACHI.png" alt="InterNachi-Home-Inspectors" width="81" height="70" /></span><span class="img-box1"><img src="images/Infrared_Certified_Small.png" alt="Thermal-Imaging-home-inspector" width="57" height="70" /></span><span class="img-box1"><img src="images/IAC_Mold_Radon.png" alt="mold-inspector" width="94" height="70" /><img src="images/Columbus-board-of-realtors.jpg" alt="mold-inspector" width="70" height="70" /></span></p> </div> </div> </div> </div> </div> </div> </div> <div class="indent"> <div class="wrapper"> <div class="col-1"> <h3><b>Contact</b> Form</h3> <form id="contacts-form" method="post" action="contact.php"> <fieldset> <div class="field"> <label>Your Name:</label> <input type="text" value="" name="name"/> </div> <div class="field"> <label>Your Phone:</label> <input type="text" value="" name="phone"/> </div> <div class="field"> <label>Your E-mail:</label> <input type="text" value="" name="text"/> </div> <div class="field"> <label>Your Message:</label> <textarea cols="1" rows="1"></textarea> </div> <div class="wrapper"><a href="contact-us.html" onClick="document.getElementById('contacts-form').submit()" class="link1"><em><b>SUBMIT</b></em></a></div> </fieldset> </form> </div> <div class="col-2"> <div class="box2"> <div class="border-top"> <div class="left-top-corner"> <div class="right-top-corner"> <div class="inner"> <h4><b>Property </b>Info</h4> <ul class="news"> <li><a href="full-loop-inspections">Sept 13, 2011</a> <p>When contacting us please provide as much information as you can about the property.</p></li> <li><a href="full-loop-inspections">Sept 13, 2011</a> <p>We will take the time to answer any questions you might have. </p></li> </ul> </div> </div> </div> </div> </div> <div class="box3"> <div class="right-bot-corner"> <div class="left-bot-corner"> <div class="inner"> <center> <p> </p> <p> </p> <p><img src="images/JPicture.jpg" alt="Home-Inspectors-Columbus" /></p> <p> <strong><font color="#FFFFFF">Full Loop Inspections<br /> Certified Home Inspector<br /> Justin Ashley<br /> 4690 Helmsbridge Ct<br /> Grove City, OH 43123<br /> (614)-256-6505</strong><br /><a href="mailto:Justin@Fullloop.net?subject=Inspection"><font color="#000000"> Justin@Fullloop.net</font></a></p> </center> </div> </div> </div> </div> </div> </div> </div> </div> <!-- FOOTER --> <div id="footer"> <div class="footer-nav"> <div class="left"> <ul> <li><a href="home.html">Home</a></li> <li><a href="inspection-services.html">Services</a></li> <li><a href="payments.html">Payments</a></li> <li><a href="contact-us.html">Contact</a></li> <li class="last"><a href="home-inspector-links.html">Links</a></li> </ul> </div> </div> <div class="bottom"><p><a href="http://www.fullloop.net" class="new_window">Full Loop Inspections</a> </p> <p>Servicing <strong>COLUMBUS</strong> - Bexley - Canal Winchester - Dublin - Gahanna - Grandview Heights - Grove City - Hilliard - New Albany - Pickerington - Reynoldsburg - Upper Arlington - Westerville - Whitehall - Worthington and all surrounding cities </p> </div> </div> </div> <script type="text/javascript"> Cufon.now(); </script> </body> </html> Hello, I have a very simple table... DAY (Y-m-d) / TIME (00:00:00) / POWER (INT) I am using a Jquery datepicker to select the date on the page, and that POST to the PHP file. I am trying to select values from Mysql to make 3 HighCharts Graphs using the selected day of the datepicker. I have started with the DAY graph PHP to get the values for each hour of a 24 hour day. I need to get the values for each hour... 23,12,15,35 etc... , and then I need for the 31 days of a month for the month graph, and 12 months of the year for the month graph all in the same way so the HighCharts can use the values to make the chart (3 php files, one for each graph) Here is the PHP I have for the 1 day that should get the 24 individual hour data, but it does not seem to work... <?php $choice = (isset($_POST['choice'])) ? date("Y-m-d",strtotime($_POST['choice'])) : date("Y-m-d"); $con = mysql_connect("localhost","root","mackie1604"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inverters", $con); $sql = "SELECT HOUR(time), COUNT(power) FROM feed WHERE time = '".$choice."' GROUP BY HOUR(time) ORDER BY HOUR(time) "; $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $row = mysql_fetch_assoc($res); echo $row['choice'].'<br />'; ?> What have a written wrong in the sql query ??? Alan hii I have made some code that works out the difference between two timecodes. IE Time 1 Time 2 Time2-Time1 1330613232 - 1330613545 = 313 Im wanting to express the difference in terms of hours. 313 as a time code is 00:06:49 but I want it to show 0.12 hours. how would I achieve this? x I would like to create function, what prints times to specified day. For example Day time total 1 10 - 12 2 2 0 (or nothing) 3 10 - 12:15 2:15 4 10:30 - 12 1:30 5 10 - 12 2 6 0 (or nothing) 7 0 (or nothing) Time comes from database and there is column for day, starting time (like 10), ending time (like 12:15) and total, calculated, time in db. So day and times come from db. Have thinked this much, but can't figure out how. Hi, I have a database where I store times with the Now(); function. What I want is: When the viewer looks at the post, instead of it saying: Posted: 2010-11-14 19:08:14, I want it to say posted: x hours ago, Posted: x days ago, etc. Any help with this would be appreciated! I have the below code wish I wish to add 12 hours to: Code: [Select] $today = date('D', mktime(0,0,0,date('m'),date('d')+0,date('Y'))); anyone to show how I add 12 hours? I have a weird issue. I'm working on something where people will submit hours for a business. Originally it was free form text, but then I figured it may get messy with people doing M-F 9-5 then Monday through Friday, 9AM to 5PM, Mon-Fri, etc. So I switched to a bunch of inputs. It has each day then a select for from and one for to. Data is passed to the script as a form submission. Vars are named HF# and HT# (hours from, hours to and a 0-6 digit for Mon-Sun). I want to take the input and output a string as such:
Mon-Tue, 8:00 AM to 5:00 PM
Thu-Fri, 8:00 AM to 5:00 PM
Sat, 9:00 AM to 1:00 PM
Sun, 12:00 PM to 3:00 PM
I did this:
$formdata = array(); $formdata["hf0"] = "8:00 AM"; $formdata["ht0"] = "4:30 PM"; $formdata["hf1"] = "8:00 AM"; $formdata["ht1"] = "4:30 PM"; $formdata["hf2"] = ""; $formdata["ht2"] = ""; $formdata["hf3"] = "8:00 AM"; $formdata["ht3"] = "4:30 PM"; $formdata["hf4"] = "8:00 AM"; $formdata["ht4"] = "4:30 PM"; $formdata["hf5"] = "9:00 AM"; $formdata["ht5"] = "1:00 PM"; $formdata["hf6"] = "12:00 PM"; $formdata["ht6"] = "3:00 PM"; $WeekDays = array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"); $hours = ""; $sd = "Mon"; $ld = ""; $fr = $formdata["hf0"]; $to = $formdata["ht0"]; for ($x=0; $x<=6; $x++) { if (empty($sd) && !empty($formdata["hf$x"])) { $sd = $WeekDays[$x]; $fr = $formdata["hf$x"]; $to = $formdata["ht$x"]; } if ($fr != $formdata["hf$x"] || $to != $formdata["ht$x"]) { $hours .= "$sd" . (($sd==$ld)?", ":" - $ld, ") . " $fr to $to<br/>"; if (!empty($formdata["hf$x"])) { $sd = $WeekDays[$x]; $fr = $formdata["hf$x"]; $to = $formdata["ht$x"]; } else { $sd = ""; } } $ld = $WeekDays[$x]; }($formdata was because I was tired of hitting back, changing the data then resubmitting) This kinda works, but it skips Sunday. There has got to be a better way to do this.. any ideas? $date = date('G:i', $row_teams['startTime']); // this date looks like this 15:30 I am trying to add 2 hours to it, any suggestions please Okay I want to run some code every 24 hours, what would be the best way to do this? Also I don't have root to the server or anything. basically could somebody help me with information on having a php script that deletes mysql rows which are older than 3 hours old. I know MYSQL table will need a date/time column but how can I only target ones which are 3 hours old+. Thanks This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=322423.0 Ok, I have a variable ($incubation) set as 04:00:00. Then I have another variable ($starttime) set to the current time. Both are printing out fine. But I'm trying to get an $endtime from adding the incubation time to the start time. Code: [Select] $incubation = $row['incubation']; //IM GRABBING THIS TIME FROM THE DATABASE. It prints 04:00:00 $starttime = date("H:i:s"); //prints 16:23:39 $endtime = date("H:i:s", $starttime+$incubation); //prints 20:00:00 when it's suppose to print 20:23:39 so i have a mysql column with a datetime and i was wondering how i could make it echo the time in "X minutes ago" or "X hours ago" and also, when its more then 24 hours old, delete the entire entry Code: [Select] $startdt = $_POST['startdt'].":".$_POST['starttmh'].":".$_POST['starttmm'].":".$_POST['sAMPM']; // 09/08/2011:11:35:AM $enddt = $_POST['enddt'].":".$_POST['endtmh'].":".$_POST['endtmm'].":".$_POST['eAMPM']; //09/09/2011:11:35:AM From the code above I want to subtract 09/08/2011:11:35:AM from 09/09/2011:11:35:AM and get the total number of hours. A simple solution would be highly appreciated: thanks in advance: |