Get time independant from server

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Get time independant from server

Post by klevis miho »

How to get the time independant from the server. I want to get the time from my zone (my server is 4 hours before).
If I need to change the server, so do I need to change the time on the scripts.

Do you know of something more efficient?

I'm thinking about an external time or something like that.
abushahin
Forum Commoner
Posts: 42
Joined: Wed Nov 25, 2009 12:35 pm
Location: london

Re: Get time independant from server

Post by abushahin »

hey im assuming from what you said that u are hosting in a country where it is a different timezone, to be able to change this one way of doing it is that you can set the timezone in your htaccess file to do that you'll need a htaccess file in the root of your server possibly public_html,

Code: Select all

php_value date.timezone "Europe/London"
thats the bit of code that goes into ur .htaccess file, obviously u need to adjust the timezone if its not London. hope that helps
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: Get time independant from server

Post by klevis miho »

I pasted exactly the code you gave me into the .htaccess file in public_html and it gives me an internal server error
abushahin
Forum Commoner
Posts: 42
Joined: Wed Nov 25, 2009 12:35 pm
Location: london

Re: Get time independant from server

Post by abushahin »

Code: Select all

php_value date.timezone "Europe/London"
Thats the bit of code in my .htaccess file and it works perfectly, unless your host doesnt allow overwrites with .htaccess then you may have to find al alternative, sorry couldnt help more at this time.
User avatar
arjan.top
Forum Contributor
Posts: 305
Joined: Sun Oct 14, 2007 4:36 am
Location: Hoče, Slovenia

Re: Get time independant from server

Post by arjan.top »

User avatar
PHPHorizons
Forum Contributor
Posts: 175
Joined: Mon Sep 14, 2009 11:38 pm

Re: Get time independant from server

Post by PHPHorizons »

I've had a problem where my htaccess file needed a line break at the end of it.

Code: Select all

 php_value date.timezone "Europe/London"
 
Hope that helps.
Post Reply