changing server time to my time
Moderator: General Moderators
changing server time to my time
Hi....... me server time is 5 hours behind me (i.e when i post news it says time is 5am instead of 10am) im sure I rerad of a way to change this but for the life of me I can not find it any more!
all help much appreciated....
mike
all help much appreciated....
mike
i am using getdate()
i am using getdate() so is their no way of it adding 5 hours to what the getdate recieves?
thanks
mike
thanks
mike
Code: Select all
$today = getdate();
$hour = $todayї'hours'] + 5;
if($hour > 23)
$hour = $hour - 24;
echo $hour;thanks but....
ok that works very well mate but.....
when the time is pushed 5 hours forward and into the next day the date isnt moving forward one--- how do i make it do that?-- this is the code as it is now (which works
)
$date = getdate();
$mday = $date['mday'];
$mon = $date['mon'];
$year = $date['year'];
$today = getdate();
$hour = $today['hours'] + 5;
if($hour > 23)
$hour = $hour - 24;
echo $hour;
$minutes = $date['minutes'];
thanks for all help
mike
when the time is pushed 5 hours forward and into the next day the date isnt moving forward one--- how do i make it do that?-- this is the code as it is now (which works
$date = getdate();
$mday = $date['mday'];
$mon = $date['mon'];
$year = $date['year'];
$today = getdate();
$hour = $today['hours'] + 5;
if($hour > 23)
$hour = $hour - 24;
echo $hour;
$minutes = $date['minutes'];
thanks for all help
mike
ok, if you're just using the current time (plus 5 hours of course), then try this....
let me know if any of that is unclear.
Code: Select all
// get UNIX timestamp (number of seconds since epoch)
$current_time = time();
// add 5 hours. 5 hours * 60 minutes * 60 seconds = 18000
$adjusted_time = $current_time + 18000;
// at this point, it depends on your database field type. if you have date
// field, you would use this
$formatted_time = date('Y-m-d', $adjusted_time);
// if you are storing the epoch formatted time in the database (such as
// in a bigint field), then you don't need to change anything
$formatted_time = $adjusted_time;
// then just insert this into your database
mysql_query("INSERT into news SET date=$formatted_time");let me know if any of that is unclear.