date("r") shows a different timing!! :(

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lmh85
Forum Commoner
Posts: 49
Joined: Sat Oct 28, 2006 10:49 am

date("r") shows a different timing!! :(

Post by lmh85 »

it shows Fri, 24 Nov 2006 09:13:08 +0000
when the current time is 5.15pm
anyone?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: date("r") shows a different timing!! :(

Post by Chris Corbyn »

lmh85 wrote:it shows Fri, 24 Nov 2006 09:13:08 +0000
when the current time is 5.15pm
anyone?
That's the time on the server. The server must be based in the UK. Where are you?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The difference would suggest GMT+6 so that's Dhaka, Bangladesh.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

09:13 + 6 hours is 15:13. He said it's 17:15 ... +8 hours.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

whoops.. my math of off from all the turkey I guess.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

lmh85
Forum Commoner
Posts: 49
Joined: Sat Oct 28, 2006 10:49 am

Post by lmh85 »

hey everyone! thanks for the reply! i'm from singapore.. i had tried "date_default_timezone_set" but it can't work as well! i can't get access to the server which is also located in singapore.. :roll: :?: :( :cry:
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

lmh85
Forum Commoner
Posts: 49
Joined: Sat Oct 28, 2006 10:49 am

Post by lmh85 »

the version of my php is 4.. so, i'm not able to use the date_default_timezone_set.. is there any other way?
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Try

Code: Select all

putenv("TZ=Etc/GMT+8");
lmh85
Forum Commoner
Posts: 49
Joined: Sat Oct 28, 2006 10:49 am

Post by lmh85 »

can't work either.. It sort of messed up my session variables :(
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

You could always alter your timestamp, but you would have to do it every time you called date:

Code: Select all

date('r', time()+(8*60));
lmh85
Forum Commoner
Posts: 49
Joined: Sat Oct 28, 2006 10:49 am

Post by lmh85 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

function fnc_date_calc($this_date,$num_days,$display){
	$my_time = strtotime ($this_date); //converts date string to UNIX timestamp
	$timestamp = $my_time + ($num_days * 86400); //calculates # of days passed ($num_days) * # seconds in a day (86400)
	if($display==1){
	$return_date = date("d-m-Y",$timestamp);  //puts the UNIX timestamp back into string format
	}else{
	$return_date = date("Y-m-d",$timestamp);  //puts the UNIX timestamp back into string format
	}
	
	return $return_date;//exit function and return string
}//end of function
i'm having this function.. which adds num days if i call it. It do work fine in my developing machine.. But not my web server.. Is there any one whom can help?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

If this isn't related to your previous post, start a new thread..
lmh85
Forum Commoner
Posts: 49
Joined: Sat Oct 28, 2006 10:49 am

Post by lmh85 »

okok.. Thanks.. I thought it was about the same! So sorry!
Post Reply