Dear Server...

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
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Dear Server...

Post by JellyFish »

Dear Server. I don't know why but when I tell you "date('Y-m-d')" you seem to think it's Friday... Please explain your logic in this: Are you thinking in GMT? I'd like you to think more on the lines of Pacific Standard Time. How could I get you to think differently?

Sincerely, Jellyfish.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Dear PHP Manual,

Thanks for showing me examples of how to do this on your page about the date() function. Oh, and thanks for the examples and the related function that is used to set the default timezone. Wow PHP Manual, that was easy and fun too.

Sincerely,

arborint
(#10850)
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

arborint wrote:Dear PHP Manual,

Thanks for showing me examples of how to do this on your page about the date() function. Oh, and thanks for the examples and the related function that is used to set the default timezone. Wow PHP Manual, that was easy and fun too.

Sincerely,

arborint
Thanks for the response. But I'm not able to use date_timezone_set() nor date_default_timezone_set(), 'cause I'm running php 4.

Is there no other way to do this?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

From looking at the manual you could do something like:

Code: Select all

$my_timezone_date = date('Y-m-d', mktime() + date('Z'));
(#10850)
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

arborint wrote:From looking at the manual you could do something like:

Code: Select all

$my_timezone_date = date('Y-m-d', mktime() + date('Z'));
I'm not understanding, what's a time stamp? This is what I have:

Code: Select all

$sql = "INSERT INTO linkcount (site, IP, date) VALUES ('YourFreeiPhone.com', '$_SERVER[REMOTE_ADDR]', '".date("Y-m-d")."')";
What should I change?
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Dear php,

Why not use my Built in Function called Now()?

Sincerely,
Mysql
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Zoxive wrote:Dear php,

Why not use my Built in Function called Now()?

Sincerely,
Mysql
Now() works exactly the same as date("Y-m-d"). But what I don't understand is, why is the result "2007-09-14"? Is it the fourteenth?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The server is likely set or located in a timezone where it is the fourteenth. Are you thinking the server should somehow magically know your timezone and display it accordingly?
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

feyd wrote:The server is likely set or located in a timezone where it is the fourteenth. Are you thinking the server should somehow magically know your timezone and display it accordingly?
No, my original question, I'm sorry I wasn't so clear, was: How can I get my server to display PST?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

arborint's post shows how to adjust the time, artificially.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

JellyFish wrote:I'm not understanding, what's a time stamp?
You can't make this stuff up:

http://www.unixtimestamp.com
(#10850)
mrkite
Forum Contributor
Posts: 104
Joined: Tue Sep 11, 2007 4:19 am

Post by mrkite »

dunno if it works from apache, but it definitely works from php-cli:

Code: Select all

putenv("TZ=MST");

// date() now uses MST
Post Reply