[PHP] Re: how to test string to see if it is a date or time?

2003-03-24 Thread DomIntCom
can anybody help me out with this?  I have figured out checkdate finally,
but still have nothing that will help me with time validation.

thanks,

Jeff
Domintcom [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I have a form that is passing a date variable, and a time variable.  I
will
 be using these for a query, and will use the date function to do some
 formatting on it.

 now, I would like to idiot proof it a bit, but can't find any functions
for
 this (hoping something similar to is_numeric exists).

 does anybody have any commands, or some code that would allow me to make
 sure a variable is a valid date or time.

 thanks,

 Jeff





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



Re: [PHP] Re: how to test string to see if it is a date or time?

2003-03-24 Thread Jason Wong
On Tuesday 25 March 2003 00:39, DomIntCom wrote:
 can anybody help me out with this?  I have figured out checkdate finally,
 but still have nothing that will help me with time validation.

explode() on the time delimiter (probably colon)
check that hour is 1-12 (or 0-23)
check that minute is 0-59
check that second is 0-59

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
If you're not very clever you should be conciliatory.
-- Benjamin Disraeli
*/


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



Re: [PHP] Re: how to test string to see if it is a date or time?

2003-03-24 Thread Erwin Kerk
Try this (as found on php.net)

$str = 'Not Good';
if (($timestamp = strtotime($str)) === -1) {
echo The string ($str) is bogus;
} else {
echo $str == . date('l dS of F Y h:i:s A',$timestamp);
}
Erwin Kerk
Web Developer @ BliXem.nl


Jason Wong wrote:
On Tuesday 25 March 2003 00:39, DomIntCom wrote:

can anybody help me out with this?  I have figured out checkdate finally,
but still have nothing that will help me with time validation.


explode() on the time delimiter (probably colon)
check that hour is 1-12 (or 0-23)
check that minute is 0-59
check that second is 0-59


--
 ____
| __|_ ___ __ _(_)_ _
| _|| '_\ V  V / | ' \ @blixem.nl (work)
|___|_|  \_/\_/|_|_||_|@scoutingnederland.nl (private)


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


Re: [PHP] Re: how to test string to see if it is a date or time?

2003-03-24 Thread DomIntCom
thanks Erwin  Jason...  I will work with these two, and see what I can come
up with.

Erwin Kerk [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Try this (as found on php.net)

 $str = 'Not Good';
 if (($timestamp = strtotime($str)) === -1) {
  echo The string ($str) is bogus;
 } else {
  echo $str == . date('l dS of F Y h:i:s A',$timestamp);
 }


 Erwin Kerk
 Web Developer @ BliXem.nl



 Jason Wong wrote:
  On Tuesday 25 March 2003 00:39, DomIntCom wrote:
 
 can anybody help me out with this?  I have figured out checkdate
finally,
 but still have nothing that will help me with time validation.
 
 
  explode() on the time delimiter (probably colon)
  check that hour is 1-12 (or 0-23)
  check that minute is 0-59
  check that second is 0-59
 


 --
   ____
 | __|_ ___ __ _(_)_ _
 | _|| '_\ V  V / | ' \ @blixem.nl (work)
 |___|_|  \_/\_/|_|_||_|@scoutingnederland.nl (private)





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



Re: [PHP] Re: how to test string to see if it is a date or time?

2003-03-24 Thread DomIntCom
here is my solution for this...

  if (($timestamp = strtotime($_POST['sdate'])) === -1)
   die (H3The start date is not a valid date format/H3);
  if (($timestamp = strtotime($_POST['edate'])) === -1)
   die (H3The end date is not a valid date format/H3);
  if (($timestamp = strtotime($_POST['stime'])) === -1)
   die (H3The start time is not a valid time format/H3);
  if (($timestamp = strtotime($_POST['etime'])) === -1)
   die (H3The end time is not a valid time format/H3);

Erwin Kerk [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Try this (as found on php.net)

 $str = 'Not Good';
 if (($timestamp = strtotime($str)) === -1) {
  echo The string ($str) is bogus;
 } else {
  echo $str == . date('l dS of F Y h:i:s A',$timestamp);
 }


 Erwin Kerk
 Web Developer @ BliXem.nl



 Jason Wong wrote:
  On Tuesday 25 March 2003 00:39, DomIntCom wrote:
 
 can anybody help me out with this?  I have figured out checkdate
finally,
 but still have nothing that will help me with time validation.
 
 
  explode() on the time delimiter (probably colon)
  check that hour is 1-12 (or 0-23)
  check that minute is 0-59
  check that second is 0-59
 


 --
   ____
 | __|_ ___ __ _(_)_ _
 | _|| '_\ V  V / | ' \ @blixem.nl (work)
 |___|_|  \_/\_/|_|_||_|@scoutingnederland.nl (private)





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