RE: [PHP] syntax for date math expressions

From: Date: Wed, 03 Apr 2002 19:16:35 +0000
Subject: RE: [PHP] syntax for date math expressions
Groups: php.general 
Request: Send a blank email to php-general+get-91373@lists.php.net to get a copy of this message
this is an option that only "sort of" works (converting to date/time); $x = strtotime("2002-04-03") - strtotime("2002-04-02"); $x will contain 86400 which is the number of seconds in a "normal" day. Since the days that some people use switch from daylight savings time to standard time (and visa versa) there are a different number of seconds in those days so simply dividing by some fixed value will not work (this is what I mean by "sort of"). Some databases have a datadiff function, perhaps you can pass a query something like SELECT datediff("2002-04-03","2002-04-02") as difference from realtable Warren Vail Tools, Metrics & Quality Processes (415) 667-7814 Pager (877) 774-9891 215 Fremont 02-658 -----Original Message----- From: Rick Emery [mailto:remery@excel.com] Sent: Wednesday, April 03, 2002 11:02 AM To: 'ROBERT MCPEAK'; php-general@lists.php.net Subject: RE: [PHP] syntax for date math expressions Convert to date/time variable and perform arithmetic. Otherwise, if these dates are from mysql, let mysql do it -----Original Message----- From: ROBERT MCPEAK [mailto:RMCPEAK@jhuccp.org] Sent: Wednesday, April 03, 2002 11:12 AM To: php-general@lists.php.net Subject: [PHP] syntax for date math expressions What is the php syntax for adding or subtracting dates? For example, I'd like to do something like this: 2002-04-03 - 2002-04-02 = 1 or 2002-04-03 - 2002-04-02 = 0000-00-01 or 2002-04-03 + 0000-00-01 = 2002-04-03 etc. Can anybody help this newbie? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#91373) next »