strtotime and strftime help plz
Posted: Tue Aug 15, 2006 2:19 pm
feyd | Please use
Plz take into consideration i am very knew and dont really know what im doing...so try not to blast me too hard on this one. If this idea is completely bogus is there another way to do this? Or am i missing the point in here somewhere?
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Ok sorry for the post on some seemingly easy to understand functions but i searched google and this forum for those keywords and couldnt find what im looking for.
Anyways on to the question. lets say i have a string of number 01012001 how would i convert this to a time format of 01 - 01 - 2001?
I have a function that probably is complete bogus but im trying to double check a users age on a payment form. Not really necessary cuz the credit card validation process will do that but i wanted to try and cut down on the errors in the form before it gets set to a cc server for validation. Hopefully trying to cut down on bandwidth used up just by simple mistakes in filling out the form. So im trying to verify the age is at least 18.
I want to make sure it is in the proper format of 01-01-2001 which i dont understand as of yet.
And output in the correct format as well. So far this is my best shot at it:Code: Select all
<?php
function DOB ($m, $d, $y) {
//Convert Date of Birth to String
$d = $_POST['BillD'];
$m = $_POST['BillM'];
$y = $_POST['BillY'];
$dob = $m . $d . $y;
//convert currnt time to string -18
$currD =date('d');
$currM =date('m');
$currY =date('Y');
$dobchk = $currM . $currD . ($currY - 18);
//Check to see if DOB is less than or equal to DOBCHK
if ($dob <= $dobchk) {
if ($frmt = date('m - d - Y', strtotime($dob, $frmt))) {
return $dob; }
}else { return false; }
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]