Times
I'm currently storing start and end times (hh:mm:ss) for shows in a
radio schedule using MySQL and processing the data with PHP.
I need to add one second to the end time to ensure it is formatted
correctly (e.g. 09:29:59 to 9:30am) however I just cannot see how to do
it *correctly* - with PHP or MySQL. I may well be overlooking something
but I would be grateful if anybody could help and point me in the right
direction.
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Intersection Of 2 Times In Php
I have to do a script that calculates the intersection of 2 times. I write it in php instead of explaining: $time1_from = "2006-02-01 08:00"; $time1_to = "2006-02-01 20:00"; $time2_from = "2006-02-01 06:00"; $time2_to = "2006-02-01 18:00"; I want the script to calculate that there are 8 hours common in those two times. And the script should work for any 2 times. And of course, where there is no intersection, the return value should be 0.
View Replies !
View Related
Changing Between Times
does anyone know to convert a time string in the form dd-mm-yyyyThh:mm:ss i.e 2006-08-01T15:45:11-00:00 to a normal unix time stamp or something that at least I can use to compare to a unix timestamp.
View Replies !
View Related
Php Dates And Times
I have a mySQL database that contains a DATETIME type column. An example entry would be "2001-08-07 17:30:58". I've pulled that value out of the table and am storing in a variable called $endtime. I want to test $endtime and do one of two things. If the datetime in the variable has not yet arrived, I want to print the time remaining to the screen. If the datetime has arrived I want to do something to my table. It will look like this: if ($endtime has not arrived) { //echo "time remaining"; } else { //mysql operations}
View Replies !
View Related
Ftp_put Times Out
I've got a script which uploads a few files to a remote server. The problem is the ftp_put command hands and the script eventually times out. What is even more strange is sometime it works fine. When it's not working i've check the connectiion and done a manual upload with a proprietry ftp program and all is fine.
View Replies !
View Related
Dates/Times
I'm making a really basic forum. When users post I want it to say "Latest post: (TIME) (DATE)" in say 22:00, then date as DD/MM/YY When I insert it into the database do I want my field to be configured as "DATE" and a field configured as "TIME" or should I use VARCHAR? But I also noticed it doesn't insert it in DD/MM/YY, it does MM/DD/YY or something weird? To insert do I just do time() and date()?
View Replies !
View Related
Times With Unix/PHP
I must first admit that I have little experience in dealing with times, and I'm not sure where to begin. I have recorded a timestamp of the current time, but when I echo this time, it reads five hours ahead of the current timezone I'm in (which is -6 hours GMT and the server is -8 GMT). I first assumed that this time was GMT -1, but then I began thinking about daylight savings time and what not, and that just got me even more confused. point me to a good article about dealing with time, or maybe give me a quick rundown of what I need to do to make the time display correctly for my current timezone (whether it's DST or not)?
View Replies !
View Related
Dates And Times
I admit it ... I am not so hot with database functions. Could someone teach me how to get 15 minutes before NOW()? i.e. SELECT userID, page, ip, happened FROM tracker WHERE happened > NOW() - 1500 ORDER BY id DESC LIMIT 0,100 I think I need something like this: SELECT userID, page, ip, happened FROM tracker WHERE happened > DATE_SUB(CONCAT(CURDATE(), CURTIME()), INTERVAL 15 MINUTE) ORDER BY id DESC LIMIT 0,100 I am not sure if the above works or not ... I don't get any errors, but nothing changes. Are both queries correct?
View Replies !
View Related
Query Add 1 X Times
I want to have a form that says My name ______________ number of entries _____ If I chose 20 entries I want to have a script query the last numerical entry and add 20 entries into mysql If I chose 40 then add 40 and so forth.
View Replies !
View Related
Multiple Times
I have a php program called from a menu where I put in information. When submitted, the form returns to the meny and leaves the screen with just the menu. I need to make 40 - 50 entries using this program (form). I put three buttons on the form, Submit-normal submit button so database can be updated, Complete - close the form and return to menu and Cancel - does the same a complete. I would like a method to keep the form on the page after submit is clicked with a "clean" form to continue making entries until the complete button is clicked.
View Replies !
View Related
2 Times Same Query
I've a query quite important to execute. I've to fill an array with all result, so the query is called once wich returns all ID's Then I call the same query a second time as I shown only 10 results in my page.
View Replies !
View Related
Compare Times
I have a session variable $_SESSION['generale']["order_time"] that contains the string "22:00:00" taken from a TIME field in a DB i need to be able to compare that with the current time that i get with date("H:i:s"); when i compare them using PHP Code: if(date("H:i:s")>$_SESSION['generale']["order_time"]){ it doesn't work, so i guess i need to do something to the times before being able to compare them.
View Replies !
View Related
A For Loop That Loops 1.5 Times
Below is some code from a page of mine that is supposed to process form data. The data is made up of checkboxes that a user randomly selects when they want to delete a file from a list of files. dbmysqlconnect_pgs(); for ($x = 0; $x <= count($checkbox); $x++) { $query2 = "SELECT name FROM proposalinfo WHERE propid='$propid' "; $results2 = mysql_query($query2) or die("Error in query 2"); while($query_data = mysql_fetch_array($results2)) { $name = $query_data["name"]; } $query4 = "SELECT filename FROM files WHERE fileid='$checkbox[$x]' AND propid='$propid' "; $results4 = mysql_query($query4) or die("Error in query 4"); while($query_data = mysql_fetch_array($results4)) { $filename = $query_data["filename"]; } //THIS IS WHERE THE ARCHIVE OF THE OLD FILE IS PROCESSED $query3 = "INSERT INTO archives (date, userid, propid, filename, fileid) VALUES (NOW(), '$userid', '$propid', '$filename', '$checkbox[$x]') "; $results3 = mysql_query($query3) or die("Error in query 3"); $query4 = "SELECT date FROM archives WHERE fileid='$checkbox[$x]' AND propid='$propid' "; $results4 = mysql_query($query4) or die("Error in query 4"); while($query_data = mysql_fetch_array($results4)) { $date = $query_data["date"]; } //THIS IS WHERE THE RENAME OF THE FILE IS PROCESSED $oldfilename=$filename; $oldname="./" . $name . "/" . $oldfilename; $newfilename=$oldfilename . $date; $newname="/overflow/pgs_archives/" . $name . "_archive/" . $newfilename; copy("$oldname", "$newname"); unlink("$oldname"); //THIS IS WHERE THE DELETE OF THE DB DATA IS PROCESSED $query5 = "DELETE FROM files WHERE fileid='$checkbox[$x]' AND propid='$propid' "; $results5 = mysql_query($query5) or die("Error in query 5"); $query6 = "DELETE FROM fileinfo WHERE fileid='$checkbox[$x]' "; $results6 = mysql_query($query6) or die("Error in query 6"); } indentheader(ཐ',',ཐ','header3','The selected files have been deleted from the system.'); The problem I am having is that this will only execute 1.5 times before failing. The failure is at query3. Basically if you selected two or more checkboxes you will only delete one of the entries. Query3 runs by itself just fine and works the first time. Anyone have any ideas?
View Replies !
View Related
Query (dates And Times)
Struggling with a query here. table name : holidays fields : holname (format varchar) holdate (format date 2004-01-01) The table is populated with all the holidays for the next 5 years. I am trying to select only 1 of each holiday for the current year, AND if todays date is past a holiday for the current year, then select the following years holiday. For example, today date would return easter, mothers day, etc. AND next years valentines (because it is past 2004-02-14). Does this make sense ?
View Replies !
View Related
Execution Times/Modules
I am encoutering the following performance problem with php 3.0.16, the latest apache, running with compiled in php_mod on a sun ultra1. i have written a set of php class files, which i use througout the site. the execution time of my skripts is very fast, but it seems that the class files i require (about 30k) slow down the performance enourmously. when i benchmark the site using ab with a php file which simply does html output and nothing else. its really fast, if i require my class files and do nothing else than the html output, the performance drops incredibly (no db connection, no computation, nothing) i always thought that php_mod also keeps a byte code for the required pages in memory (like for example perl_mod). but now i doubt that. it seems that every request, forces php_mod to reload and recompile (or totally interpret ?!?!??) every file needed. is there anyway to increase performance when using multiple phpclass files? I know of conditional includes, but thats IMHO not a pretty solution.
View Replies !
View Related
Find A Way To Subtract Two Times
I have spent the last few hours trying to find a way to subtract two times, none of the information that I find seems relevant to what I am trying to do... A technician is filling out a form, posting the time he logs in and the time he logs out, both of which are being recorded in the database. But prior to the UPDATE, I need to calculate how many hours he was there, e.g. 2.5 hours, then post that also ... then multiply that times his hourly rate and post that also, which ultimately gives the times he was there, how many hours total and how much his time cost against the work, but I think I'm getting off subject... here's my latest failure for code. Code:
View Replies !
View Related
Run Code Every 3 Times In A While Loop
I need a certain block of code to run inside a while loop every 3 times its run but I cant figure out how to write it. I came up with a sort of static fix but I need it to be more expandable. Here is what I've got inside the loop so far. if ($num == 3 || $num == 6 || $num == 9 || $num == 12 || $num == 15 || $num == 18 || $num == 21 || $num == 24 ect...) { echo('</tr><tr>');} The loop output 3 profiles with images and names on each line and then goes to a new line for the next 3 using tables. Is there a way to write this so it runs every 3 on to infinity and not have to input the numbers manualy?
View Replies !
View Related
Using Same Recordset Multiple Times
I've created a recordset and want to use it to populate the contents of multiple drop-down menus. To do this once is easy enough, but the number of drop-down menus is created dynamically based on a number entered on a previous page. I've done a 'do while' loop to create all of the drop-downs, and nested another 'do while' loop inside the <SELECT> field to populate the contents from the recordset. However, only one drop-down menu populates, the others stay blank. I've run into similar problems before, and it seems that I can't use the same recordset more than once. Is that correct, or have I made a fundamental mistake? Code:
View Replies !
View Related
Display The Number Of Times
Say I have a picture thats a link, or a text link. how would i, in php display the number of times it was clicked. for instance: *link* hits:# here btw i sux at php and have like 5 books on it but nothing really sticks. anyone know video tutorials for it? i used a video series for visual basic and became really good.
View Replies !
View Related
Quantifier Matches 0 Or More Times
quantifier matches 0 or more times. is this normal to be true or false preg_match ("/tras*hformers/" , "trashforsmers"); // FALSE (tutorial says it should be true preg_match ("/tras*hformers/" , "trashformersss"); // TRUE i'm wondering couse i found one tutorial, and now when i test it looks like it's wrong. i guess the whole pattern must be true AND then after the pattern if any 's' were found it will also be true.
View Replies !
View Related
Show Number Of Times
What I am wanting to to is to have a database that has multiple values stored in it and be able to show the number of times a certain value is found in a specific column. For example A|B|C ------- 1|2|4 2|2|5 5|6|9 the number of times 9 is found in column C is 1.
View Replies !
View Related
Script Running 3 Times
<?php if($page=="" || $page=="Home") { include("includes/Home.php"); } else { if(file_exists("includes/$page.php")) { include("includes/$page.php"); } else { include("includes/404.php"); } } ?> I use this code for including the main pages of my site while keeping the banner and such constant. Code:
View Replies !
View Related
Add Two Times Together To Equal A New Time
I am trying to add two times together to equal a new time. I have the following $Arrive = 03:45:00 $duration = 00:30:00 $depart2 = date("H:i:s", strtotime("+1 hour".$Arrive)); $depart2 would now be 04:45:00 how can I add the duration to this number to give me the final time of 05:15:00 .
View Replies !
View Related
Adding Times / Percentages Etc.
I am trying to do the following add time fields from a db together so that I can work out the total number of hours. The field in the db that I want to add is a TIME field, how do I add this together? When I add then tohether normally such as PHP Code: $total_time += $row['time']; I get a integer, how do I solve this?
View Replies !
View Related
Posting Many Times To Page
I have a situation where I need to post alot of data to a legacy system we have and it takes a long time for the system to do the inserts. I was wondering if there is a way to post without waiting for the response, so I could do say 15 posts one right after another and it would open 15 connections but not wait for them or put them in the background. Preferably without forking if its possible.
View Replies !
View Related
Number Of Minutes Etc. Between Two Times
OK I have two timestamps. One is the value for the current time. The second is a time that a song was last played. <? $select = mysql_query("SELECT * FROM songs ORDER BY lastplayed DESC LIMIT 1"); // returns latest played song $songinfo = mysql_fetch_array($select); $todaysdate = date("YmdHis"); $songlastplay=$songinfo[lastplayed]; ?> Say for example the value of $songlastplay for this particular song was "20070213005812" and the current date were "20070213012056". How would one work out how many days, hours, minutes and seconds were between these two dates?
View Replies !
View Related
Subtract 2 Dates/times
I have two dates with times like this: Start date/time = 2006-01-01 08:12 End date/time = 2006-01-07 10:45 I want to take the End date/time and subtract Start date/time from it. I want the results in days, hours and minutes. Like this example: 4 days, 3 hours and 52 minutes.
View Replies !
View Related
24 Hours Format Times
how do i go about working the elapsed time in hours beteween two 24 hour times: heres my general code PHP Code: <?php $to = $_POST['totime']; ///// first 24 hour time $land = $_POST['landtime']; ///// Second 24 hour time $ICAO = $_POST['LandICAO']; ///// Landing Airport $frame = $_POST['frame']; ///// a/c Frame Number $fnltime = "$land - $to"; echo $fnltime ?> problem being i need to to still be able to work it out if the person set one time as say 1800 and the 2nd time as 0200.
View Replies !
View Related
Repeat As Many Times As User Specify Then Stop
I'm trying to write a script that uses and tag called steps to creat a tutorial database. This is how it works. the user comes to the page and chooses how many steps are in there tutorial. The $steps are always resubmitted to the same page depending on how many steps the are part shown and the bottom repeats until it reaches that value. My Problem I don't know grab the value submitted and make it repeat til that value is match. <form name="form"> <select name="site" size=1 onChange="javascript:formHandler()"> <?php $count = 0; while($count <= 24) { $count++; echo "<option value="submittut.php?steps=$count"> $count</option>"; }; if ($steps != 0) ------------------------> Part 2 { echo "<br><br><table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td rowspan="2" valign="middle"><font size="+2"></font> </td> <td bgcolor="#cacaca"> <div align="center"> <b>Upload the corresponding picture here</b></div> </td> <td bgcolor="#cacaca"> <div align="center"> <b> Paste your the Text and HTML into the text are below</b></div> </td> </tr> <tr> <td valign="middle"> <div align="center"> <br> <input type="file" name="fileGetterName" size="26" border="0"></div> </td> <td> <div align="center"> <br> <textarea name="textareaName" rows="4" cols="40"></textarea></div> </td> </tr>"; } while () ?>
View Replies !
View Related
Script Executes Multiple Times?
I've got a file of code that is included in a page. I recently made a change to the code and now the script executes multiple times. In the main file, I've got this: if ( $_SERVER[SERVER_NAME] == "www.domain.com" ) { $pagename = 'index' $hitcount = 'X' include("include/userlog.php"); } In userlog.php, I've got this: $dt_logged = date("Y-n-j H:i:s"); $ip_addr = GetHostByName($REMOTE_ADDR); @ $db = mysql_pconnect("localhost", "x", "x"); if (!$db) { print 'Error: Could not connect to database. Please try again later.' exit; } mysql_select_db("dbname"); $insert_query = "insert into tablename values ('".$dt_logged."', '".$ip_addr."', '". $pagename."', '".$hitcount."', '".$pagevar."', '".$searchterm."')"; $insert_result = mysql_query($insert_query) or die(mysql_error()); It worked before I changed the database structure. I reduced the number of columns and now it seems that the included file executes twice and, for the second execution, does not take the variables set in the main file into account. So, I get two rows added to my table...one with all variables, even the ones set in the main file; and a second row with just the IP address and date.
View Replies !
View Related
Strip Tags With Contents N Times
What is the best way to delete tags n times from either the beginning or the end of a String? For example, to delete "someString1" and "someString2" along with surrounding <someTag>'s with n=2 and processing direction is from beginning. $someBigString="<someTag>someString1</someTag><someTag>someString2</someTag><someTag>someString3</someTag>"; I was thinking about use preg_replace() to replace "/</tag><tag/" with "" but wasn't sure how, especially about the n times and direction of processing.
View Replies !
View Related
Slow Response Times (php + MySQL)
so my site is finally done but the main page takes about 4-5 seconds to load. It's about 50KB and I have a 1.5 MB DSL so it's not the loading time. Right now it searches through about 1500 records and returns about 50 of them with name, URL, image and a few other options. The site is not public yet and I notice that mysql take 60-90+% of the CPU but barely 3% of the memory when I call that page. Tried it plenty of times to make sure that's why it spiked. What's scaring is that the records will increase to at least 10,000. I have eAccelerator and I have no problems with a php-nuke site with way more records. It loads really fast, but I have removed a lot of the bells and whistles; here I need them. The server: Fedora II, a 2.4 P4, 1 GB Ram, MySQL 3.58, server load almost never goes above 0.50, even during the "delays" and when mysql taking 98%. After an OS /Apache 2.0 upgrade, I've noticed that I only have one mysql proccess running, before I had dozens. Is this better or worse? [root@********etc]# more my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock [mysql.server] user=mysql basedir=/var/lib [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid I have no problems with individual pages at all in this site. What do you guys suggest? Is my .cnf the problem? Unfortunately the program is finished, too late for database changes, if that's the problem. Can I "cache" the index page with an additional program and update it manually or every hour or so? Eventually I will upgrade to MySQL 4.* but right now I am swamped with updating and testing the new site and can't risk downtime. Any help would be greatly appreciated. some more mysql data, in case it makes sense to someone ;): ------------------------ system locking is not in use Possible variables for option --set-variable (-O) are: back_log current value: 50 bdb_cache_size current value: 8388600 bdb_log_buffer_size current value: 0 bdb_max_lock current value: 10000 bdb_lock_max current value: 10000 binlog_cache_size current value: 32768 connect_timeout current value: 5 delayed_insert_timeout current value: 300 delayed_insert_limit current value: 100 delayed_queue_size current value: 1000 flush_time current value: 0 innodb_mirrored_log_groups current value: 1 innodb_log_files_in_group current value: 2 innodb_log_file_size current value: 5242880 innodb_log_buffer_size current value: 1048576 innodb_buffer_pool_size current value: 8388608 innodb_additional_mem_pool_size current value: 1048576 innodb_file_io_threads current value: 4 innodb_lock_wait_timeout current value: 50 innodb_thread_concurrency current value: 8 innodb_force_recovery current value: 0 interactive_timeout current value: 28800 join_buffer_size current value: 131072 key_buffer_size current value: 8388600 long_query_time current value: 10 lower_case_table_names current value: 0 max_allowed_packet current value: 1048576 max_binlog_cache_size current value: 4294967295 max_binlog_size current value: 1073741824 max_connections current value: 100 max_connect_errors current value: 10 max_delayed_threads current value: 20 max_heap_table_size current value: 16777216 max_join_size current value: 4294967295 max_sort_length current value: 1024 max_tmp_tables current value: 32 max_user_connections current value: 0 max_write_lock_count current value: 4294967295 myisam_max_extra_sort_file_size current value: 256 myisam_max_sort_file_size current value: 2047 myisam_sort_buffer_size current value: 8388608 net_buffer_length current value: 16384 net_retry_count current value: 10 net_read_timeout current value: 30 net_write_timeout current value: 60 open_files_limit current value: 0 query_buffer_size current value: 0 record_buffer current value: 131072 record_rnd_buffer current value: 0 slave_net_timeout current value: 3600 slow_launch_time current value: 2 sort_buffer current value: 2097144 table_cache current value: 64 thread_concurrency current value: 10 thread_cache_size current value: 0 tmp_table_size current value: 33554432 thread_stack current value: 65536 wait_timeout current value: 28800
View Replies !
View Related
Finding Time Difference Between Two Times.
I want to have a script that reports the last activity that a user had, and stores that in a database. So I'll pass there PHP Sess ID into the URL's, and then update the database with each link they click on. When they come back later and login again, I need to find out the time difference between the two logins, as I want to give people credits every hour, and don't want to have to run a cron to do this, so instead I just work out the time difference when they relogin and allocate them credits accordingly (its a game). I am no good at working with dates though. There is so many formats - so I wouldn't have a clue which would be the best to use, especially when you want to do calculations with it. I donno if a MySQL time stamp would be good, as when they relogin the value will be generated with PHP, not from MySQL.
View Replies !
View Related
Loading Times For Php Generated Pages
I've just noticed on my own surfing of the net and some php pages that i've done. especially long pages.... that they seem to load in blocks... one section at a time is there some sort of buffering or something that is doing this and can be turned off? I"m not that experienced in php... but know enough.
View Replies !
View Related
|