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
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
2 Different Time Zones
I have 4 sites sharing an account on a server that is in the US Eastern time zone. 3 of those sites are for businesses/persons who live in the same time zone, but one is for a restaurant in the US Pacific time zone. For that site, I want to generate content via a script depending on the local Pacific time and day of week. The content will change at the same time every day: one page before 5:00am local time, a different page from 5am until 10pm, then back to the first page after 10pm. The script should also generate appropriate last modified and expires headers. It'd be nice if this script were portable, in case I change hosting companies and wind up with a host in European time, or US central time, or what have you. At the moment, my script gets the local time of the server (US ET), converts it to UT with date("Z"), then converts it again to Pacific time: $utTimeStamp = time() - date("Z"); $daylightSavingsTime = date("I"); $PT = $utTimeStamp - (8*3600) + ($daylightSavingsTime*3600); That's fine for the current time, but trying to work out expires times seems rather complicated, and I'm having a hard time getting everything to work. Is there an easier way to accomplish my tasks? Should I give up some portability and simply convert from one local time to another?
RSS Feed For World Time Zones
I am working on different country projects, where the delivery time of the project will be saved on their respective country timings.We need to display the time in IST time zone accordingly. I need to calculate the time difference between different india and other countries. For that is there any RSS live feed available to get the time difference between two countries. (dynamic values of the time difference according to the countries).
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??
Displaying Current Time
Hi I want to display the current time in PST using php. I want it to appear like this: October 21st, 9:46 PM PST but the closest I can figure out is this.. November 10, 15:36 PST using this code...
Displaying Current Time
I have a PHP page in that I need to show the current time in Paris, France. How can I do it?
Displaying Local Time
How do you display a users local time. I have looked through some help files and they seem to all seem to be showing me how to use the time in conjuction with something else.
Php Displaying Last Modification Time
Trying to get a php script to display when a web page was last modified. My code is below, i'm getting a last modified date of dec. 31 1969 which is wrong for one, and does not change if i modify the resulting file. The code itself is in an include file, a footer file, which will be included at the bottom of every page. Suggestions? <? echo "This file was last modified: "; $temp = pathinfo($PHP_SELF); echo strftime("%A %B %d, %Y", filemtime($temp["basename"])); ?>
Displaying Date/time
I'm trying to display a datetime type which I save with NOW() ie: // create query $query = "INSERT INTO purchase (category, location, price, time) VALUES ('$category', '$location', '$price', NOW())"; time is a datetime type I want to just display the "time" part of time, not the date this is the code I'm using: echo "<li><a href=".$_SERVER['PHP_SELF']."?category=".$row[5].">".date("G.i:s", $row[5]."</li>"; and getting a "Parse error: syntax error, unexpected ';' ..."
Displaying Rounded Time
Looking to see if there is a way to round time to the nearest half hour, so no matter what time is displayed, the nearest half hour is displayed. ie: If time displayed is 1:12AM - regardless, round it up to 1:30AM -- 1:01AM still rounds to 1:30AM -- Is this possible? Was unable to find anything on google to do this..
Displaying Page Render Time
Some sites (some forum software etc) have a line at the bottom of the page that says Page rendered in 0.0002414 seconds or something of that ilk. My question is - how would one code this? The only way I could think would be to take the time at the top of the page and the time at the bottom of the page, take one from the other and display that - am I on the right track?
Date/time Displaying Wrong
How do I set the time display to echo the time, in the timezone the user is in and not the server time. For somereason im in eastern timezone and the host server i9s in central and the time displayed on my laptop is in central.
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.
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:
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()?
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?
Use Of PHP Sockets, And Using Perl To Modify DNS Zones...
I have it set up so the address bnls.dementedminds.net will redirect to a live server, and if the server goes down, it'll go through a list in a mysql table seeking the next available live server, and upon finding one, it will modify the DNS zone tables to point to the alternative server, and reload the named service. As hackish as it seems, it apparently works. Code:
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...?
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?
|