Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to check php variable has datetime value?

Tags:

php

I have a php variable which contain date-time value like 2014-05-11 23:10:11 some times this may change, so i have to find it either it has date-time value or not, below is my variable

$my-variable='2014-08-26 18:25:47';

1 Answers

DateTime is a class in PHP. You should ask a different question if you want to validate a string. To validate a DateTime instance:

$my_variable instanceof DateTime
like image 108
Ryan Avatar answered Nov 29 '25 22:11

Ryan