Determining If Time Falls Into Time Frame
I am having problems determining whether the current time falls into a certain time frame. I want to be able to allow my users to set a start and end time of when they do not want to be disturbed.
for example: between 11pm and 3am every day. I would then store this as 23:00:00 and 03:00:00 in a table. If the times were on the same day then this code would work:
PHP Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Determining Date/time
I'm retreiving all timestamps by user_id from a database and want to print to screen the week that the date falls in. For example, if I retrieve today's date - 07/24/01, a tuesday, I want to create a link - 07/24/01-07/29/01. (which is Monday - Sunday.) I want to retrieve all of the timestamps, and loop out the results in the format above (eg. 07/24/01-07/29/01) for every date in the table. The results would look like this: 07/24/01-07/29/01 07/30/01-08/05/01 08/06/01-08/12/01 Sample code that I have is below, I have been going back and forth trying to do this with mysql functions, or doing it with php date() The second query is commented out, but this was another way that I was considering doing this. I can't figure out how to find the week, Monday-Sunday, of any given date. Sample Code:
Determining First Time Link Is Clicked
I am currently working on a site using php and mySql with a restricted user area. The admin of the site has the ability to update messages and upload pdf files for their users. When user A logs in the messages specific to user A are retrieved from the database. Also I use a script to check the user specific folder for files and these are then shown as links allowing them to view the pdf files. Now I am looking for a way to determine when a link to a pdf file is followed the first time only, so an email can be send.
Determining Local Date/time, Given GMT And Offset
I'm trying to create a function that returns the local date/time if you feed it a GMT date/time and the local offset. For example i live in MST so i think it's GMT-7. This is the function i've created, but it's returning weird values. didn't work for me last night, but mysteriously worked this morning. maybe something screwy with AM vs PM? I'm passing the date in the format "Y-m-d H:i:s". I'm not so good with date calculations obviously. Code:
Problems With Php Date/time - Real Time Clock
On my website i would like to have a real time clock....i mean to show seconds running one after another...how can i do this? Another problem is how to get time into a variable (which then i will insert into a database table)?
Adjusting Time Displays For User's Local Time
I have a news/comment site where stories and comments are accompanied by the date they were posted. Currently I'm doing that in the GMT format, simply because it's easiest. What I'd like to do, however, is have the page display posts and comments with "your time," i.e., the local time of the user (example of what I'm talking about here). I know how to get local time variables from a user with javascript, but I'm not sure how to pass that information to PHP, especially since I'd like to do this on the front page, which means no passing javascript information via query strings.
Convertint Time String To Time Stamp
I want to convert the time string from the if-modified-since header into a unix time stamp, so I looked at the strtotime() function. The PHP manual on that function makes reference to a GNU manual page, which indicates that only UTC and Z are unambiguous. However, a last-modified-header is followed by "GMT". They are synonymous, but can I safely use it with strtotime()?
Displaying Time In Different Time Zones
I'm trying to get to grips with times, and as an exercise am trying to create a function to display the time in various places. The way I'm currently doing this is as follows: // ------------------------------- putenv("TZ=GMT"); //set to GMT $time_to_convert = mktime(15,0,0); //gives me 3pm GMT echo(strftime('%d/%m/%y %H:%M',$time_to_convert)); //3pm putenv("TZ=CET"); echo(strftime('%d/%m/%y %H:%M',$time_to_convert)); //7pm // ------------------------------- That seems to work fine, and gives me the dates in the various places. The question I have, is how can I determine if a given country is in daylight-savings? Essentially, what I want to achieve is a list that will tell me what time it is in a given country right now. (A bit like the World Clock
Time Difference Change Over Time
Is there a way to print the time different depending on how long the time has been. So like if the user has not been logged in for 24 hours or more... it will say 1 day rather than 24 hours. And if its less than 1 hour it will say it in minutes... and if its greater than 1 hour but less than 1 day it will say minutes and hours? This is my query which i have done so far but don't know how to do the above checking! //get register date and now date $GetLoginDate = mysql_query("SELECT DATEDIFF(NOW(), LoginDate) AS LastLogin FROM userregistration WHERE UserID='{$_SESSION['Current_User']}'") or die(mysql_error()); $lastlogin = mysql_fetch_assoc($GetLoginDate);
Show Time In Local Time
I tried searching for the answer, but didn't really get anything back. Maybe it's the terminology I was using. Can anyone help me in a direction for how to change what time zone a time is displayed for? My timestamps default to California and would like to show them as EST. Or even show the time in whatever time zone the person viewing the time is in. Does that sentence make sense?
PHP To Select Chance - 50% Of Time X - 50% Of Time Y
I'm sure this is very simple, and I believe has something to do with generating random numbers (although I could be wrong). What I need is simple, code that will show picture X 50% of the time, and picture Y 50% of the time. So that the views on each picture will be exactly the same.
Php.ini Sets Max Time To 90 Seconds, Yet I Get A "Max Execution Time Of 30 Seconds Exceeded"
This is weird. When I use getId3 to try to read meta tags out of multimedia files, I get this error: Fatal error: Maximum execution time of 30 seconds exceeded in /home/ httpd/vhosts/bluewallmultimedia.com/httpdocs/getid3/getid3/ getid3.lib.php on line 54 But if I run phpinfo(), I get this: max_execution_time9595 and if I ssh to the server and look in php.ini, this is confirmed: max_execution_time = 95 ; Maximum execution time of each script, in seconds This is on a RackSpace server, running RedHat. It's got Plesk installed.
Switching From 24 Hour Time To 12 Hour Time
In a form I enter a time. The database stores it in a 24 hour format, but I want it to be displayed on the users screen in 12 hour format. For example, Instead of 16:30 I want to have the output displayed as 4:30pm. How do I achieve this? For what it is worth I am using PHP 4.0.4 and mySQL 3.23.22-beta.
Last Time
I have tried posting 3 times today and had every post wiped and a error screen that said "no forum selected" or some such nonsense. There is some serious problem with posting in this forum as I have had this happen before, on too many occasions.
Time
How to get d server time in php .... and how to fine year(not system date yr) in server side like use of calendar functions...
Time
I would like to view the time when entering my site, in the format: 18:09 Does anybody know a solution for this?
Php - Time Until You Hit
Heya, I havn't worked with the time functions of PHP much, and im having an issue with something i thought would be rather simple. All i want to do is display how many hours/minutes/seconds are left until you hit 17:30 or 5:30 pm. I thought ok thats easy. Get current time - 17:30. I thought it would work like lets say its 17:00 17:00 - 17:30 = -30 that what i want the - 30 minutes until 17:30 If you do this in PHP with mktime(19,30,00,01,01,1970); and time(); It actually comes out as 10:30. So i tried a range of other things but couldn't seem to get it to just return how long until the time i made. Code: $thistime = time(); $mktime = mktime(19,30,00,01,01,1970); $timeuntil = $thistime - $mktime; <?php echo date("H:i:s a", $timeuntil);?> Run that and you will see what i mean.
Time!
I just can't catch the drift when dealing with dates and times. First I need a simple script to convert a "human" entered date (ie 12-9-2000) from a form to unix time. Can I use a <input text... >? Then I need to convert unix time back into a "human" form to display when reading to a page. Again 12-9-2000. All this time I am having trouble setting up mySQL table. Do I set the startdate and enddate columns as INT or TIMESTAMP.
Getting Time?
I have a date in a table like so 2002-03-21. now you can see that it is 2 days and 1 year from today, 2003-03-23 I need to get that date (the old one) and find out how many days it is behind time() but here is the catch. I have a column that holds a variable on how many months to add to that old date. if there is no field (lets call it renew) then it is just adding a 12 months (1 year) to the old date. so actually the old date could be like this 2001-03-21 with the renew field at 1. so here is the question. how can I get it? I tired the following code and it is so far out of whack I don't know wha tis wrong. by the code you should see what I want. but if not here I will try to explain. if the final variable is 0 or 1 then I send a email, if the final variable is 0 and I sent an email I send another one to disable the said individual. PHP Code:
Time()
how do I make the time() function display the current time in GMT?
Time.....
I am pretty new to this so forgive me it is it a silly question.... I am setting a 15 minute cookie using time()+900. This works but I would like to inform the user of the expiration time in a hh:mm format... What I need to know is how to convert time()+900 into HH:MM.
Time Log App
I am writing an application that an IT support company can use to log time everytime they visit a customer which will then get the customers 'allocated monthly hour allowance' and remove the time the log from this. It is only a relatively simple app but I am having trouble with the following code that I have attached. The hours are stored in the database in decimal format and I have got the attached code to convert the decimal value into hours and minutes and show it in HH:MM format. I want to be able to split the text box which the IT tech enters their time (currently they still have to enter in decimal format) into two boxes HH and MM so that it is easier for them to do so. I would also like the code to automatically remove this data from the database - currently the code I have written only works out the time left on the maintenance contract if you include the previous hours you have entered. For example - if I had been working somewhere for an hour and a half today but worked three hours yesterday I would have to put 4.5 into the text box. I want to be able to put 1.5.
Time Of Day
I need to print a section of an html page only if the time is after 5:00am and before 9:00pm local time (Seattle, WA: GMT -0800 during standard time, GMT -0700 during daylight savings time). I found a bewildering number of functions for getting local or GMT timestamps, and formatting them. But I can't find anything that will return the time of day. Am I missing something obvious? Or must I put together my own function to get time of day?
Time
anyone know a way to look at say 2007-07-01 and if its over 30 days old switch it to new month?
How To Use PHP Time?
I'm trying to figure out how to get php variables as the time. One variable for the hour and one variable for the minute or one variable for both. Right now im looking at this example that i found on google.. <?php $localtime_assoc = localtime(time(), true); print_r($localtime_assoc); ?> Its outputting.. QuoteArray ( [tm_sec] => 24 [tm_min] => 3 [tm_hour] => 19 [tm_mday] => 3 [tm_mon] => 3 [tm_year] => 105 [tm_wday] => 0 [tm_yday] => 92 [tm_isdst] => 1 ) So my question is, how do I take the array value's of [tm_min] and [tm_hour] and get them into php integer variables such as $hour and $minute? Any other easy ways to do this that doesn't involve this code?
PHP Time.
What PHP function or code do i need to get the GB Time. [UK Time GMT] ? To display on the site?
IF/THEN With Time
I'd like to use an if/then statement on a certain page making it work during certain times. For example, if time is between 6pm - 10am, then A else B, what code would I need for that?
Time
I am using this for time and date: $tiempo = date('l dS of F Y h:i:s A',strtotime('tomorrow')); How would i do this: If current server time is after 12pm or $miles above 100 $tiempo = date('l dS of F Y h:i:s A',strtotime('tomorrow')); else $tiempo = date('l dS of F Y h:i:s A'); Can someone translate this to code? It's the "after 12pm part that i am having trouble with. if(date('h') > 12pm || $miles >=100){ $tiempo = date('l dS of F Y h:i:s A',strtotime('tomorrow')); }else{ $tiempo = date('l dS of F Y h:i:s A'); }
Time
I am facing problem in converting to time. select sec_to_time(unix_timestamp(now())-unix_timestamp(timestamp)) from Tablename where name= '".$name."'"; Here when values exceeds 838:59:59 how to get the exact value of time. Other than sec_to_time() is there any other function which gives the exact value
PHP Time()
I need to store in a database the time in one hour. Then i need to pull the stored time out compare it to the current time and display how long left. If there still is time left until the future time then it should do something and if it has already passed the stored time it should do something else and update the stored time to an hour from now. This has put a brick wall infront of me and a few work friends as we cannot display the time left or be certain that our whole script works as its is a mess of other peoples and has been scraped.
PHP Time
I tried this code: <?php echo date('d'):?> I thought it would work. but it gives me a error.
Time()
how would I get the number code for date() for exactly 2 months ago?
Php Time ()
I have a script to generate the local time. My local time here is ISD 6:50pm. This is the script $timestamp = time() ; $hr=time(); echo $hr; $current_time=strftime("%I:%M %p",$timestamp) ; but i get a time as 1:10pm aand so .not the rite time. is there anythn wrong?
Date And Time...
What is the best way to display the date and time on a website...? I am using php for my database queries and don't have a problem displaying the date and time on ".php" pages... however I was wondering if anybody had a suggestion on ".htm" pages...?
Displaying Time
I've got a question for yers. I've got this newsfeed and the way the time is formatted is like this: 11:18:13 Question, I've setup a time field in the DB and assigned it timestamp type field, so when I insert the time into DB it enters this as 000000000000. How do I get it to insert the time in this format 11:18:13?? Is there a such way? Perhaps I then need to use the time function to output back, yeah??
Session Time
I have changed the following in my php.ini file filesession.gc_maxlifetime = 60 session.cookie_lifetime = 60 So in theory all of my sessions should not last longer than 1 minute. But I`m still roaming round on session based pages. I`m fairly sure my code on these pages is ok: if($PHPSESSID) { session_start(); // Connect to MySQL $connection=mysql_connect("", "", ""); // Check Login against database $UserChk=mysql_db_query($dbase,"SELECT * FROM Members Where UserName='$UserName' and Password='$Password'"); $num_rowsUserChk = mysql_num_rows($UserChk); if($num_rowsUserChk==0) { header("Location: http://www.domain.com/login/login.php"); die; } }else { header("Location: http://www.domain.com/login/login.php"); die; } Is there anything else I`m missing?? Do I need to restart something or other?
Date And Time Help
I have a mySQL field that is a timestamp(14). I know that mySQL's NOW() function will insert the current timestamp into that field, but I need to do it a little different. I have a variable called $days that may be 30, 60, or 90, and I want my database to hold the equivalent of NOW() + $days. For example, I might need the value of the timestamp to be 30 days from the present. I figure the best way to do this is to use PHP's mktime() to construct a $futuretime variable that holds the timstamp I want and then insert it into mySQL and bypass the use of mySQL's NOW(). Can someone offer advice on how to do it this way, or on a better solution?
The Time () Function
I've been trying to create a useronline script for the past hour I'm done everything accept I can't seem to get the users to dissapear when they haven't been active for 30 seconds I'm not exactly sure how to do this but i checked out php.net and they only told me that the time() funtions gives you the seconds since unix has been running (?) or somthing like that lol. I cant remember Anyways could someone help me out, what I wanna do is count down 30 seconds and then erase the usersonline field 'activity' if they we're not active for 30 seconds.
Time, Timestamp?
I have a mysql db that contains a timestamp= 20010626114705 When I use getdate() to convert this to the correct date I get: $today = getdate($tijd); $month = $today['month']; $year = $today['year']; $mday = $today['mday']; $hours = $today['hours']; $minutes = $today['minutes']; $weekday = $today['weekday']; echo "$weekday $mday $month, $year $hours : $minutes"; = Monday 18 January, 2038 22 : 14 any ideas what is going wrong?
Time Calculation With Php
users of my web site enter time and distance of a run the did into a http-form. the data will be processed by a php-script and stored in an mysql-database. what i want to do is to calculate from the data what time they needed for a 1k-run -> i.e.: if one runs 12k in one hour it will be 5 minutes for 1k. the problem is, the data from the textfield of the form comes in as a string and hence i just can't divide the data ride away. time input should look like: 1:00:00 distance input should look like: 12 and output should look like: 0:05:00 any ideas?
ISE 500 Due To Overloading / Time-out
I have a long script that sends a bunch of emails (between 5 and 20). At the end of the script, it creates a Internal Server Error 500 - sometimes only. The more emails I send , the more likely it seems that I get the error. The whole script runs though - it seems (error occurs somewhere near or at the end). I imagine it either to be server overload OR a time-out (it takes about 30 seconds for the script to run (which I think relates the email send part...)
Active Time
I am wondering if their is a way to have the time update itself without refreshing the page?
Server Time
Let's say that my server time is for some reason incorrect! Is there a php function that would automaticly correct that time (give or take a few minutes, hours, days...) so date() function would return real time/date!
Using Time Stamps For A What's New
I have a database of Native American drum groups using PHP and MySQL. In each record I have a time stamp on it. I'd like to create a What's New type page, where it would show the newest 10 records.
Time Zone
i have a script that enters the date into a mysql database. I have a field named timestamp which is a datetime column type. I insert the value with the now() function. The problem is my server is on eastern time and I'm in central time. I know that I want to use the following for the parameters for date: M j Y, h:i a I also know (or think I do) that the correct equation to subtract an hour would be this: +(60*60*(-1)) However, that is where I am stuck. How do I convert $row->timestamp into the date above with the math for converting the time zone?
|