Re: getting funny error on working page
| From: | Andrew Ballard | Date: | Tue, 15 Apr 2008 21:43:03 +0000 |
| Subject: | Re: getting funny error on working page | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-273015@lists.php.net to get a copy of this message | ||
On Tue, Apr 15, 2008 at 5:24 PM, John A DAVIS <John.A.Davis@state.or.us> wrote:
>
>
> Thanks! My guess is the production server has this set correctly and I will
> follow your advice.
> However, how would one do away with this error? What would I do to guarantee
> an string being returned instead of a date? What can I wrap the date()
> function in?
>
> $month=substr($thisdate,0,2);
> $day =substr($thisdate,3,2);
> $year = substr($thisdate,6,4);
>
> $d =date("M d (D)",Mktime(0,0,0,$month,$day,$year));
>
>
> Again, thank you!
> John A. Davis
I don't think you need to wrap date() in anything, as it should be
returning a string. Without seeing the actual input that caused the
warning, I think it's probably more an issue with either $month, $day,
or $year not being quite right (but close enough that PHP can still
obtain the correct result). Is it possible (since you're getting the
date from a database query) that the value is coming back as a
datetime string that includes a time portion? Your function should
work OK if you are getting something that looks like '10-02-2008
10:15:27' but will get the error you reported if it gets the same
value as '10022008 10:15:27'. Try doing a var_dump on each value to
make sure it's what you expect it to be.
Andrew