php 5.3 - PHP Substring output with 2 params -
i have php code this,my output correct ?date format (yy/mm/dd)
year month & date format >> 120924( it's 2012/09/24)
$yearchk=(int)substr($date,0,4); $monthchk=(int)substr($date,5,2); $daychk=(int)substr($date,8,2);
in here there's substring.is output correct in substring.
my yearchk output > 12 monthck output > 09 daychk output > 24
is outputs correct ?
don't use substr.
use date , strtotime function, this.
do way:-
<? $userdate = "2012/09/24"; $y = date('y',strtotime($userdate)); $m = date('m',strtotime($userdate)); $d = date('d',strtotime($userdate)); echo 'year: ' . $y . ' month: ' . $m . ' date: ' . $d;
refer live demo
Comments
Post a Comment