![]() |
Calculating differences
Hi,
I'm trying to build a simple countdown and I'm hitting a snag when comparing dates. I've got db fields for dates that appear like this: 01-14-2005. I can split the date to 01/14/2005 or 2005-01-14 all with no problem. By default they are 2005-01-14 and I've split them to 01-14-2005. I want to compare that date with the date("m-d-Y") php function and print the difference on a page I've tried a simply subtraction command: PHP Code:
PHP Code:
01-21-2005 01-14-2005 But the $ct variable returns 0 instead of the 7 I'd expect. Any help would be appreciated. Also, since my db field does not track time (hour minute seconds) is there a way I can get a constant like 12:00 am to compare to the current time with mktime(); ? Thanks |
Okay no help there so how about splitting a string?
I've worked out the calculation but I'm having trouble splitting the result string. My string returns 7 digits 101023454 - 1 digit day, 2 digit hour, 2 digit minute and 2 digit second. I need to add a leading 0 for the one digit day if it's not a 2 digit number. Then I need to split the string every 2 digits here's the code I'm using: PHP Code:
Can someone tell me how to split that string please? I don't know how to split strings without it already delimitated. I'm still searching php.net and google but I'm having little luck. Thanks |
Nevermind. Got it all worked out.
|
considered converting your date to a unix timestamp doing your calculation and converting back?
|
uhmm. no. I'm not that proficient yet. Would that be more efficient?
|
All times are GMT. The time now is 09:00 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|