Jump to content

Date/Time String Validation


cyber0ne

Recommended Posts

I have a form where the user inputs DateTime values. They are "encouraged" to use the format:MM/DD/YYYY HH:mmWhat I need to do in my code, however, is validate the input from the form. I need to make sure that what they enter is a complete and valid date/time. Then, I need to re-format it to this:YYYYMMDDHHmmSS (where SS will just be 00)I'm still pretty new to PHP, but is there anything built-in that can help me with this? Maybe create some kind of datetime object with the passed string, use that object to check its own validity (assuming it didn't error out on creating it with an invalid string), and get output from that object in a custom format?Any help would be much appreciated, thank you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...