my variable is a dynamic string variable in this string i have some date value and looks like
$var = 'bd','100','10-05-2013','20-05-2013','alise';
but i want to change this date format like
$var = 'bd','100','2013-05-10','2013-05-20','alise';
my variable is dynamic so date position and number of dates not fixed.
Thanks
I recommend using strtotime (see http://php.net/manual/en/function.strtotime.php). You can iterate over the var (explode if you need) and check whether false is returned. Everything else hopefully was a meaningful date/date time and is now a timestamp.
i use this and its work fine. thanks to all.
$var = preg_replace("/([0-9]{2})-([0-9]{2})-([0-9]{4})/i","$3-$2-$1",$var);