Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 16th, 2004, 11:52 AM
Authorized User
 
Join Date: Dec 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help comparing dates

I have a date variable ($start_date) that I build with MKTIME.

I would like to compate this date to the current date ($today). To make matters worse, I need to adjust $today for the time zone (some users on the client side are on the other side of the International Dateline).

I'm seeking some advice on the best way to compare $start_date to $today.


 
Old December 20th, 2004, 12:15 PM
Authorized User
 
Join Date: Dec 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to peg110
Default

First you will need someway to determine the time zone the user is in. The only way I can think of to do that is to have them somehow pass that information to you.

Typically the various date functions are calculated off the SERVERs time.

The ways to compare are depending upon WHAT you want to compare... The DAY, the HOUR, the Year, The MONTH DAY YEAR, etc.... Comparison is relatively easy using the UNIX timestamp since it's basic math (calculating the number of seconds within the comparison period). Without more information, I don't think I could be much more help, but I hope this helps get you in the right direction.



Paul Gardner
------------------
PHP-LIVE help
Via Web @ http://www.mnetweb.co.uk/irc
Via IRC Client pgardner.net:6667
room #PHP
 
Old December 20th, 2004, 12:43 PM
Authorized User
 
Join Date: Dec 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Paul for your input. I think I am a bit fuzzy of the difference between gmdate and date, the latter being the "local" time/date. Does that mean the "local server" time/date as opposed to the GMT time/date? If so, then is date(Z, timestamp) the timezone offset of the server?

Is there no way of reading the TZ setting of the client (Windows Control Panel) with some client-side scripting and using it to compute the "local client" time/date?

 
Old December 20th, 2004, 04:03 PM
Authorized User
 
Join Date: Dec 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to peg110
Default

gmdate gives the LOCAL TIME (of your server) in GMT Time. So if your local server is set for Eastern Time then at 5PM (local time) gmdate will give you a time of 12PM (Eastern Time - 5 hours) Again, as far as I know, with JUST PHP, you cannot get the timezone information (directly).

That being said, there are ways to determine it, but again, it has to be done CLIENT SIDE. I have found a few sites that might be useful in determining this.

http://www.siteexperts.com/tips/func...ng.asp?main=on
http://martin.f2o.org/php/localtime

I think that second link would probably be more helpful.



Paul Gardner
------------------
PHP-LIVE help
Via Web @ http://www.mnetweb.co.uk/irc
Via IRC Client pgardner.net:6667
room #PHP





Similar Threads
Thread Thread Starter Forum Replies Last Post
comparing dates help. warhero XSLT 1 July 5th, 2007 09:41 AM
Comparing dates Tomi XSLT 1 September 21st, 2006 04:45 AM
Comparing Dates in XSLT kwilliams XSLT 7 December 1st, 2005 08:49 PM
Comparing Dates bennybee JSP Basics 1 April 3rd, 2005 09:31 PM
Comparing Dates Issue tdaustin Classic ASP Basics 2 June 2nd, 2004 06:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.