cyber0ne Posted August 30, 2006 Share Posted August 30, 2006 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 More sharing options...
reportingsjr Posted August 30, 2006 Share Posted August 30, 2006 You will need to use preg_replace, I recommend going to php.net and searching the functions list for that, it will help you! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now