PHP - Moved: Calculating Time On Pages And Site
This topic has been moved to Application Design.
http://www.phpfreaks.com/forums/index.php?topic=355963.0 Similar TutorialsThis topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348274.0 I have collected some data from .xml api's and I need to manipulate it in a way to display something specific.
not my strongest point when it comes to maths & date data.
so ultimately I need it to echo something like the following:
"3 Days 4 Hours Remaining" or "14 Hours Remaining" (if below 24 hours!!!)
I use the following to pull my variables and to test by echo results.
<?php // Calculate total Fuel blocks $itemID = $record['itemID']; $result = mysql_query("SELECT * FROM `ecmt_poslistdetails` WHERE itemID = '$itemID' AND (typeID='4051' OR typeID='4247' OR typeID='4246' OR typeID='4312')"); $row = mysql_fetch_array($result); $fuelQty = $row[quantity]; echo $fuelQty; ?> <br /> <?php // Calculate total Fuel blocks used per hour $typeID = $record['typeID']; $result = mysql_query("SELECT * FROM `ecmt_posfuel` WHERE typeID = $typeID"); $row = mysql_fetch_array($result); $fuelUse = $row['fuel']; echo $fuelUse; ?>this gives me: $fuelQty & $fuelUse so for instance if fuel quantity is: 18480 and $fuelUse is: 40 the fuel used is 40x per hour and time remaining would be 462x Hours remaining but I want it to display: 19 Days 6 Hours Remaining how can I achieve this format? I've been researching online resources and seen a lot of code and functions for calculating an interval or difference between two date/time figures. What I'm trying to do is somewhat in reverse... I want to establish an interval to determine a past date/time to be used in a MySQL Query but just can't figure the critical part.
// STEP #1 = DEFINE THE DESIRED DATE/TIME DIFFERENCE INTERVAL DESIRED FOR QUERIES $timeinterval = '60'; // Interval is in MINUTES and can be changed as desired // STEP #2 = GET THE CURRENT LOCAL SERVER DATE/TIME // as YYYY-MM-DD HH:MN:SE $serverdatetime = date('Y-m-d H:i:s'); // My local Server Date & time // STEP #3 = CALCULATE THE ***PAST** (OLDER) DATE/TIME LIMIT BASED ON $timeinterval (Minutes) // as YYY-MM-DD HH:MN:SE $pastdatetime = [stuckinarut here] <- 60 MINUTES prior to current Server Date/Time // STEP #4 = MySQL QUERY (`submitted` column is auto-timestampped on record insertions) $sql="[columnsblahblah] FROM mydb WHERE `submitted` >= $pastdatetime";In a Perfect World, the MySQL Query would yield ONLY records with a `submitted` DATE/TIME equal to 60 Minutes (or less) PRIOR TO from the Current Server Time. Any assistance is appreciated! Thanks. -FreakingOUT This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=353188.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=316461.0 I have a table where I'm storing my marathon and other race results. One column ( race_time_total - TIME format) and another column ( race_distance_numeric - decimal(65,3) format) are being used here.
Assuming the race_distance_numeric is the distance of the race in either km or miles (Eg: marathon being 42.195km), how to I calculate the pace?
I've used:
$pace_per_k = $row_content['race_time_total'] / $row_content['race_distance_numeric'].... but am not getting expected results when I echo $pace_per_k Any tips? I have no idea where to start or which board would be the proper place to put this but what I"m attempting to do is integrate this idea with my custom cms I'm making now is that once inside I can take down my site in case I (administrator) wanted to perform some maintenance on my site and have it instead display a custom 404 page. Any ideas on where to start. I tried using my best friend google but he gave me nothing. Maybe a few tutorials of this might help. Hi, Having completed a site migration this am everything went well aside from issues with logging into and out of our site where two files are used and appear as white pages. When logging into our site, proc_login.php is used and when logging out proc_logout.php is used. Both processes result in a white "blank" page instead of the php files forwarding on. I've no idea about php generally and have been trying my best to find useful and similar information online to attempt to resolve the problem. I am now stuck. The site works perfectly on my local web server, and what is really baffling me is the site also works perfectly on Domain B on the exact same server I'm trying to get the site running under as Domain A. In other words as both Domain A & B are configured on the same host server I'm thinking all the inherited php/apache/mysql settings should be identical (or pretty much thereabouts) and therefore am more confused than ever! I simply don't know where to start therefore in resolving this problem. I've tried looking in the error log file and have also played around with turning on error enabling on those specific php files to try and follow any errors, however the "errors" generated are no different than the ones present on sites where the login/logout process works just fine. I've hopefully attached both files and if anyone could assist in helping me narrow down my search for a solution I'd be very appreciative. Thanks. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=352551.0 Hello, I have some questions about dates/time ... I have a site where registered users will receive messages, I want to include the date/time with that message. I am not sure what is best way to do this, so I am recording the GMT hours offset from users input (from receivers), but then I saw that the hours offset from the GMT is different in different seasons of the year, so how do I detect correct local time for the message receiver? Is it something like a database with start-end time of daylight savings hour adjustment or how is this done? This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=354302.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=346715.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=349989.0 Great conversation, wrong board. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=357967.0 hiii all, i want to show the database field (alise name) as the url after index.php when page or site loads first time. how i can achieve it? please help.... thanks in advance Hey everyone. Currently I have a site set up where I manually edit the txt file and the site pulls it from the text file and displays via php. I wanted to automate it by creating one file which contains the sunset times for the whole year, and have php determine todays date and then display the corresponding sunset time. Can someone please point me in the right direction? maybe it can be set up in a way where each line in the txt file represents the day of the year. ex: Jan 1 would be line 0, Feb 1's sunset time would be on line 31 etc. Thanks This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=318858.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=358122.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=356195.0 This topic has been moved to PHP Math Help. http://www.phpfreaks.com/forums/index.php?topic=328102.0 |