Create time to be able to check against current time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

Create time to be able to check against current time

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post by Celauran »

If you have PHP >= 5.3.0, DateTime() will make your life a lot easier. If not, check out mktime().
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

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

Post by litebearer »

what datatype are you using for storing the dob?
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

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

Post by phphelpme »

Code: Select all

strtotime('day month year')
Best wishes
Post Reply