Re: A relative date puzzle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/1/2013 2:05 PM, Jim Giner wrote:
I'm looking for some ideas on how to handle the following get a datetime
value that is relative to a specific future date when presented with a
partial day &time value.

Specifically, I have an appl that requires some lengthy input involving
days and times.  I have streamlined the d/e effort so that it can be
done entirely using the number keypad (if available), or else just with
numeric entries.  Works great, very quick (JS) and accurate.  Basically
the users type some numbers and end up with something like:

Sat 08:00am  or Fri 07:00pm etc.

Does anyone have an idea on how I can convert this value to a true
datetime value for my database updates, where the above value is
relative to a specific date in the future?  IE, the d/e takes place a
few days before a certain upcoming date and I want my entry of "Sat" to
translate to the Saturday following that certain date.  This could take
place one to two weeks prior to the start date, so just adding "next" to
the value above won't work.  I really need to incorporate a specific
date in the solution.

Thoughts anyone?
For those interested - the proposed answer is indeed the answer.

To convert a relative time string such as "Sat 01:00pm" to an absolute date relative to a given date this does the trick:

$dt = strtotime("sat 01:00pm",strtotime("2012-11-16")

which would return "11/17/12 01:00 pm"

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux