• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 768
  • Last Modified:

want to set the timezone in mysql also

<?php
   echo date_default_timezone_get();
   $currenttime = date('h:i:s:u');
   list($hrs,$mins,$secs,$msecs) = split(':',$currenttime);
   echo " => $hrs:$mins:$secs\n";

   date_default_timezone_set('US/Eastern');
   echo date_default_timezone_get();
   $currenttime = date('h:i:s:u');
   list($hrs,$mins,$secs,$msecs) = split(':',$currenttime);
   echo " => $hrs:$mins:$secs\n";

   date_default_timezone_set('America/New_York');
   echo date_default_timezone_get();
   $currenttime = date('h:i:s:u');
   list($hrs,$mins,$secs,$msecs) = split(':',$currenttime);
   echo " => $hrs:$mins:$secs\n";

?>

Open in new window


but this mysql query keeps the timezone of the server
mysql_query("update table set sent=NOW() ");
0
rgb192
Asked:
rgb192
  • 3
  • 2
  • 2
  • +1
3 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
You can change the time zone according to this page: https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html   However, if you are on a shared server, you must set the time zone for your connection every time you connect on a new PHP page.
0
 
Loganathan NatarajanLAMP DeveloperCommented:
0
 
rgb192Author Commented:
i think these are similar links to mysql.com

I am using godaddy shared server

and mysql thinks it is mountain time zone

do I have to contact godaddy
because I do not have command line access to
mysql> SET GLOBAL time_zone = timezone;



>>However, if you are on a shared server, you must set the time zone for your connection every time you connect on a new PHP page.

is this done in php/mysql connection string
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Loganathan NatarajanLAMP DeveloperCommented:
yes, you can execute the timezone query
0
 
rgb192Author Commented:
>>
See the part about "Storing Date" in this article.
http://dev.mysql.com/doc/refman/5.5/en/datetime.html

I can not find 'insert a date 1 hour more'


>>
Use a query that says something like SET time_zone = '+00:00' to adjust the value in MySQL



I found this in your article but this query does not change the result in shared server, I have not tried localhost yet
0
 
Ray PaseurCommented:
change the result in shared server...
Do not depend on a shared server if you want to control these sorts of things.  If this is an important part of your app, you really need to have more control than a shared server will give you.

Dedicated hosting from Rackspace or LiquidWeb will give you this capability.  You might also consider using SliceHost -- but ask first to verify that they can set this up the way you want.
http://en.wikipedia.org/wiki/Dedicated_hosting_service
0
 
rgb192Author Commented:
thanks

best answer is
this wont work BECAUSE i am using a shared server
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now