Jump to content

Recommended Posts

Make the time your own time. For example if they are 3 hours behind you:

 

<?php
$hour = date(g);
$minutes = date(i);
$seconds = date(s);

$my_hour = $hour + 3;

echo "$my_hour:$minutes:$seconds";
?>

If that doesnt work for you you can check out [url]www.php.net/date[/url]. I believe there is a way to set the timezone.

If you want a php based web site to appear to be in any time zone, just set the default time zone setting to be the time zone you want that site to use for all date/time functions.

 

Ref: http://us.php.net/manual/en/datetime.configuration.php#ini.date.timezone

oh i see the difference now.

so that means when i use the "now()" function while saving sth in mysql. It will save the wrong date and time wont it ?

 

PFMaBiSmAd ;

i think i cant edit the php.ini file. I m a newbie i just bought a hosting plan with cpanel. and i think when i change the php.ini file, Can i change the date and time setting just for a web site ? or will it effect to all my websites ?

For mysql functions that are dependent on the time zone, you can do the following after you connect to the mysql server (taken from the mysql manual) -

 

Per-connection time zones. Each client that connects has its own time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement:

 

mysql> SET time_zone = timezone;

 

To setup any web site, you should be able to put the time zone setting into a local php.ini (when php is running as a CGI application) or in a .htaccess file (when php is running as an Apache module) for each site.

For mysql functions that are dependent on the time zone, you can do the following after you connect to the mysql server (taken from the mysql manual) -

 

Per-connection time zones. Each client that connects has its own time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement:

 

mysql> SET time_zone = timezone;

 

To setup any web site, you should be able to put the time zone setting into a local php.ini (when php is running as a CGI application) or in a .htaccess file (when php is running as an Apache module) for each site.

That "timezone" is for what ? a variable like "$timezone = gmt+2"  ??

I will be glad if you can explain it.

What / where should i write

.htaccess ? php file ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.