Jump to content

validate date time using regex or another option


autofocus

Recommended Posts

Hi.

 

i have a form with date , time and credit card information.

 

i want to validate date, time, credit card number format(after customer select card type from visa amex and mastercard)

 

do i have to use regex?

 

or is there any built in method in php to check date and time.

 

thanks

Link to comment
Share on other sites

It kind of depends on how you let the user input the date and time. You may have to convert their input accordingly. But, you may want to take a look at the following functions:

 

For date only:

http://us3.php.net/manual/en/function.checkdate.php

 

For a date & time (but a failure will not tell you which one failed)

http://us3.php.net/manual/en/function.strtotime.php

 

I'd suggest using the first function to validate the date and then use a custom function for validating the time. Again, this depends on what the input parameters are.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.