Jump to content

checkdate if statement


dadamssg

Recommended Posts

does anyone know how to incorporate checkdate() into an if statement. the only way i know how to use it is to put var_dump in front of it and it will output bool(true) or bool(false). i want to check their birthday to make sure its a valid date. if anyone knows how to do this thatd be awesome, otherwise, does anyone know what you get if you put in a false date in strtotime...ie. strotime(feb 31 2009)? will that ouput 00-00-0000? cause if thats the case i could just use a < or > sign to compare timestamps to a number..thanks

Link to comment
https://forums.phpfreaks.com/topic/150524-checkdate-if-statement/
Share on other sites

<?php

var_dump(strtotime('feb 31 2009'));

 

That code outputs: int(1236056400)

 

It would appear that the function simply adjusts the time. So that'd be like March 2nd (I think)

 

As far as the checkdate, you should be able to just put it in an if as is.

 

if (checkdate(2009, 13, 40)) {
   echo "this is a good date";
} else {
   echo "this is a bad date";
}

 

Since the function outputs either true or false, it's a "condition" that's highly usable in an if with out comparing to anything (i.e., using ===  or => and so on)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.