Re: How should I ....--its a date/timestamp issue

From: Date: Thu, 19 Feb 2009 02:29:13 +0000
Subject: Re: How should I ....--its a date/timestamp issue
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-288585@lists.php.net to get a copy of this message
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

« previous php.general (#288585) next »