I want to make a MLM website which need to work in Indian Timezone. and my hosting company's time is different from indian timezone..
is there any way i can make the date in php and mysql have the date and time of India. ??
Date difference due to different Time Zones
Moderator: General Moderators
-
nikhilvijayanv
- Forum Newbie
- Posts: 2
- Joined: Sun Jan 20, 2008 8:44 am
Re: Date difference due to different Time Zones
Try date_default_timezone_set()
Example:
Result:

Example:
Code: Select all
<?php
echo date('Y:m:d H:i:s')."<br />";
date_default_timezone_set('Asia/Calcutta');
echo date('Y:m:d H:i:s');
?>Note that this only affects php's scripting, not the MySQL itself. It should however be easy enough to understand what to do from here.2008:01:20 16:32:48
2008:01:20 22:02:48
-
nikhilvijayanv
- Forum Newbie
- Posts: 2
- Joined: Sun Jan 20, 2008 8:44 am
Re: Date difference due to different Time Zones
Thanks for helping.. this function is only supported in php 5 ..
What would i have to do if i am using php 4.. just curious to know
What would i have to do if i am using php 4.. just curious to know
Re: Date difference due to different Time Zones
Move to PHP5? 
Re: Date difference due to different Time Zones
Yah, but...Oren wrote:Move to PHP5?
a) not all have that power over their hosts...
b) making scripts that works for both 4 and 5 is a big plus...
Code: Select all
<?php
echo date('Y:m:d H:i:s')."<br />";
// PHP 5
// date_default_timezone_set('Asia/Calcutta');
// echo date('Y:m:d H:i:s');
// PHP 4
putenv("TZ=Asia/Calcutta");
echo date('Y:m:d H:i:s');
?>Re: Date difference due to different Time Zones
Why not? "I want PHP5 or I move to another host". If they can't give you what you need, move on to another one who can.JAM wrote:not all have that power over their hosts...
It is? Sorry I didn't know, I thought it was exactly the opposite... ask our very kind (JAM wrote:making scripts that works for both 4 and 5 is a big plus...
Re: Date difference due to different Time Zones
Sorry if I misunderstood.Oren wrote:Why not? "I want PHP5 or I move to another host". If they can't give you what you need, move on to another one who can.JAM wrote:not all have that power over their hosts...
It is? Sorry I didn't know, I thought it was exactly the opposite... ask our very kind (JAM wrote:making scripts that works for both 4 and 5 is a big plus...) Chris Corbyn and see what he thinks about it.
I thought the question was about to solve the issue using the existing 'tools'. Yes, striking a deal like suggested with the host might be in order and solve the issue, but that wasn't really the question? And the asking Chris anything... I just don't understand your point.
It's really off-topic anyways, so...
@ nikhilvijayanv :
Did it work as wanted?
Re: Date difference due to different Time Zones
Continuing on the off-topic for a teeny weeny while longer (sorry): Should I say welcome back JAM? :]
Knew I recognised your name from before when I was a PHP toddler
Knew I recognised your name from before when I was a PHP toddler