Page 1 of 1

Create time to be able to check against current time

Posted: Wed Mar 28, 2012 11:28 am
by lovelf
Hello, I am doing a birthday reminder, with the month and the day of the birthday I need to make a time with the current year for this year's birthday.

Code: Select all

$month="January";
$day="5";
$year="2012";
How to make a time on a variable as a timestamp with those variables to be able to check against the current time and see the time difference between the two, I already have a function to check between time differences but it parses a time in the format of timestamp so I need to create a timestamp with $month, $day and $year.

Thanks.

Re: Create time to be able to check against current time

Posted: Wed Mar 28, 2012 11:35 am
by Celauran
If you have PHP >= 5.3.0, DateTime() will make your life a lot easier. If not, check out mktime().

Re: Create time to be able to check against current time

Posted: Wed Mar 28, 2012 12:47 pm
by litebearer
what datatype are you using for storing the dob?

Re: Create time to be able to check against current time

Posted: Wed Mar 28, 2012 4:16 pm
by phphelpme

Code: Select all

strtotime('day month year')
Best wishes