Re: How should I ....--its a date/timestamp issue
| From: | Frank Stanovcak | Date: | Tue, 03 Mar 2009 05:07:40 +0000 |
| Subject: | Re: How should I ....--its a date/timestamp issue | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-289110@lists.php.net to get a copy of this message | ||
"Paul M Foster" <paulf@quillandmouse.com> wrote in message
news:20090219022913.GL18160@quillandmouse.com...
> On Wed, Feb 18, 2009 at 05:25:16PM -0600, Terion Miller wrote:
>
> <snip>
>
>> What about just accepting any date in to the system, and defaulting
>> to
>> the current date if any numptys/users try to set one before?
>>
>> Do something maybe like this (untested)
>>
>> $userDate = strtotime($_REQUEST['date']);
>> $startDate = ($userDate < time())?time():$userDate;
>>
>> >From there, you can use the timestamp how you wish.
>>
>> OOH found it:
>> $startday = mktime(0, 0, 0, date("m") , date("d")+2,
>> date("Y"));
>>
>> Well no, guess I didn't find it because that code above gives me
>> this 1235109600
>>
>> What is that??
>
> It's a *nix timestamp number. Give it to date() this way:
>
> date('Y-m-d', $startday)
>
> And you'll see the date it represents. (It's actually the number of
> seconds since, the Unix epoch, in 1970.)
>
> Paul
>
> --
> Paul M. Foster
Sorry been gone a while.
I usually double validate. Once in javascript to make sure the date is
valid before submit, and then again in php incase some maroon screws around
and/or has javascript disabled on their system. Hope that helps even if it
is a bit late.