Re: A little confused
| From: | Stuart Dallas | Date: | Tue, 23 Apr 2013 10:16:21 +0000 |
| Subject: | Re: A little confused | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-320966@lists.php.net to get a copy of this message | ||
On 23 Apr 2013, at 11:13, Chris Knipe <savage@savage.za.org> wrote:
> Yes,
>
> strtotime() does convert the $_SESSION value to a unix epoc, as expected. However, date_format
> still complains that the argument is a Integer value, instead of a DateTime.
Sorry, I didn't read your email properly and didn't realise you were trying to use
DateTime objects.
$datetime = new DateTime('2013-04-23');
If all you're doing is formatting the date you'll find using date($unix_timestamp) far
more efficient than date_format($datetime_object).
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
> On Tue, Apr 23, 2013 at 12:09 PM, Stuart Dallas <stuart@3ft9.com> wrote:
> On 23 Apr 2013, at 11:07, "Chris Knipe" <savage@savage.za.org> wrote:
>
> > $_SESSION['ExpiryDate'] = "2013-04-23";
> > echo date_format($_SESSION['ExpiryDate'], "D, \t\h\e jS \o\f M Y");
> >
> > Required Result: Mon, the 23rd of Apr 2013
> >
> > I get however: PHP Warning: date_format() expects parameter 1 to be
> > DateTime, integer given in
> >
> > I've had a look at the date/time function list, but I cannot seem to find
> > any way to convert $_SESSION['ExpiryDate'] to an DateTime??
>
> http://php.net/strtotime
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
>
>
>
> --
>
> Regards,
> Chris Knipe