PHP - Local Computer Time
Hey,
I'm trying to code a page which is supposed to bring up the time of a person's computer. Is this possible without majorly complicated coding? I'm good with GMT offsets and stuff but I don't know how to get the time of a person's computer. I don't want other stuff, just the time so I can edit the time based on where they are. I don't know if I'm making sense so here's an example... If someone does a forum post at 2pm Sydney time but it's 5pm Perth time. How can I make it so that someone in Perth sees 5pm but someone in Sydney sees 2pm...without them manually telling me their timezone? I read about using IP addresses but don't know much (Ok anything) about this , any hints or good sites to view would be appreciated? Or the answer if it's not too complex. Preferably I'd like to get the time in the 11 digit "time()" format so I can use it in tables and translate it with an existing function. IceKat Similar TutorialsPHP date and time function is not showing correct time on my local system I have the following php code date_default_timezone_set("Africa/Lagos"); $date = date('d-m-y h:i:s'); echo "Server Time ".$date ."<br>"; echo "The time is " . date("h:i:sa")."<br>"; $current_datetime = date("Y-m-d") . ' ' . date("H:i:s", STRTOTIME(date('h:i:sa'))); echo "Current time1: ".$current_datetime . "<br>";
Output
Server Time 21-05-21 09:55:39
Expected Output
Server Time 21-05-21 10:55:39
Any help would be appreciated. Edited May 21 by Ponel PHP 5.2.6 We rent PHP server space on a server in California. Several of my pages generated by PHP show the current date and time, so when the page is printed, the user knows when the data was printed. Our users could be anywhere in the US, I am in Michigan. How do I convert the server time (PDT) into local time, regardless of where the user is? Thanks. heres is my code for time but it ddnt the time i get was not same in my computer Code: [Select] $date = date("y-d-m") . " at " . date("h:i:s"); $time = time(); I am trying to get local date/time. In my php file I am setting my timezone using $timezone = "America/Toronto"; putenv ('TZ=' . $timezone); Then I use the following to get current date and time print_r (getdate()); but my date displays in GMT, What am I doing wrong? As in the code above I am in Toronto and I need EST. im wondering is there any easy way to echo server time and local time... without converting them from unix to timestamp i have found thi code, but i cant tell is it server or local Code: [Select] echo date("H:i" ,time()); I have all the dates stored in my database as UTC and I want to retrieves these UTC date/time to show the local time zone. So, example, If I live in New York, I want it to show east coast time zone and not the Universal Time. Any idea? How to output a MySQL timestamp field to correct local time with daylight saving with PHP?
Local time is set in php.ini with: date.timezone = "Europe/London"
Confirmed set with: <?php echo date_default_timezone_get(); ?>
But when I echo the timestamp field it does not display correct UK time for the record (an hour behind correct UK time).
<?php echo date('jS F Y - g:ia', strtotime($row['Date'])); ?>
Hello Everyone, I am on windows server and In my ini file server time zone declared as below
[server_settings] but my application installed on another timezone eg: 'America/Los_Angeles' time zone. using date_default_timezone_get() i am always getting Europe/London timezone as it's declared in ini file. How to get local timezone(wherever application is installed) here? Thanks Krish Is there a way to get my visitors PC or Device Name? I am not looking for server name or ip. I need to get my current visitors computer name. Example: MAIN, HOME, OFFICE, TOM32154}}{|\] like when first naming a PC with a new windows install. I have used sessions before I don't know whats going on. My sessions wont die. this is what im doing: <?php session_start(); $_SESSION['user'] = $_POST['email']; $_SESSION['pass'] = $_POST['pass']; ?> ok new page <?php session_start(); echo $_SESSION['user']; echo "<br>"; echo $_SESSION['pass'] ?> OK great is show the same info but now if I close my browser and go back to the second page where it echos it still shows the user//pass I have tried restarting and it still saves the dam session! Should it kill the session if i close my browser? wtf? i have recently bought a new samsung netbook so i downloaded the latest version of WAMP to develop my site. However when i run my site i get the internal server error associated with the htaccess file. The thing is that this file works on my desktop pc. The version i have of WAMP on this netbook is newer than the one i have at home, socould this be the problem? i can post the contents of the htaccess file if you think it will help, its just a lot of rewrite rules. Thanks Hi all, I've created a data-entry HTML page that posts to update.php. I am using mysql to store the data entered. When I enter data and hit "update database" button, the php file pops up and correctly shows the data entered, but the update.php file does not show that same data on another computer. I have checked the mysql database and it clearly shows that it the new data has been stored. Why isn't the data showing up on any other computer? I can provide codes as needed. Thanks. Richard I am trying to pull in computer information using PHP for program compatibility and want to know if it is possible and if so, what functions to use. I am running php on one computer at work and want other users on other computers to access the index page by sharing it.after mapping the page, I see no data on the other machine. Does php, as pache need to beer installed on other computers footer it too work properly Hi, i have problem with libraries, with fpdf and PHPEcel, problem is same... Can't open file C:\xampp\htdocs\skripta\.... - this is path to php script on my computer everything work ok on localhost when i test, but when i upload to web server, pdf script try to create file with old windows path: Can't open file C:\xampp\htdocs\skripta\, and not with linux path... does anyone have solution, and why is that? I know about
<input type="file" >which allows one to upload files from one’s computer. But now I need a pop-up window that allows the user to choose first if he uploads from his computer or from the internet. How may I achieve that ? This question is perhaps better suited for the "Javascript" or even "AJAX" forum ; if someone advises me to, I will move that question and put it in the appropriate forum. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=318425.0 Hi, I have a challenging dilema. A client keeps track of his stock using a microsoft access database in store. His ecommerce website which is hosted elsewhere uses php and mysql. Is it possible to to integrate the 2 so that when someone buys a product from the website, the store MS access database is updated to reflect this and vice versa? If so how would I go about it? Thanks in advance. P.S: I'm extremely tempted to suggest that he should stop using his ms access db and instead reccommend that I set him up a suitable backend on his website for keeping stock control, then he just login to that in the store. Hello Good day,
I am have a project for company. Can you please give me advice on how will I going to determine each computer assigned to each employee.
I have my own working unit (PC), of course that i used to login on our company web site. But when someone try to log in on our web site using their own account on my working unit it will be registered as fraud.
My problem is how will i am going to check if accountTwo try to log in on accountOne pc unit. Right now we're using cookie but if they use other browser or private browser the data on the cookie was not send on the request.
Righ now I am trying to determine using Mac Address of each PC, but still can't figure out how to get the Mac Address. It gives the server address where the site was hosted.
Is there a reason why on my local machine with php, my login system works, but then when I upload my files and test it on my web host, the login system doesn't work properly. I'm using the same php version on my local machine and on my webhost, so I don't understand why it wouldn't work the same. When I try logging in on my webhost, everything processes as normal when a correct user/pass combo is found in the database, however, my session just doesn't seem to be saved, and therefore I won't be logged in. It'll end up refreshing to the home page (as I have it setup), but it won't show me as logged in. Is there something special I need to do in order for the session to be stored correctly? (I realize I haven't pasted any code, but I'm not sure exactly how much code would be needed for me to show in order to resolve the issue). |