|
Posted by Pupkin on 10/09/06 06:25
Thanks so much.
I had tried strtotime() before, but obviously on a string that wasn't
fully compliant, and the comparison to time() is just what I needed.
Thanks!
In article <2006100718522375249-onembk@spamsomeoneelsegmailcom>,
onembk@spamsomeoneelse.gmail.com says...
> $livedate = strtotime("October 06 2006 17:45"); // converts your date
> to a unix timestamp
> if (time() > $livedate) {
> ?>
> content
> <?
> }
> ?>
>
> strtotime() will convert just about any date format you can throw at
> it, then they can be compared numerically. Convert them back with
> date("r", $timestamp); You'll avoid having to worry about date formats
> entirely.
>
> On 2006-10-06 18:13:28 -0600, Pupkin <spamagnet@dorrk.com> said:
>
> > Hi,
> >
> > I need to set some content to only show after a given date and time.
> >
> > Like:
> >
> > <?
> > $livedate = "October 06 2006 17:45";
> > if (date("r") > $livedate) { ?>
> > Content here
> > <? } ?>
> >
> >
> > I'm used to ASP, where I've gotten into trouble by not forcing my text
> > string date/time into the datetime format, so the if-then statement was
> > not comparing like-to-like (and several days or hours later, when a
> > single digit element changed to two-digits, the code would return
> > unintended results).
> >
> > Is this something I need to worry about with PHP?
> >
> > I've tried some experiments force-formatting my text string date/time
> > with date($livedate), mktime(livedate), etc., but I never end up with
> > anything that resembles the date("r").
> >
> > What do I need to learn to get this to work with reliable results?
> >
> > Thanks.
>
>
>
[Back to original message]
|