We help IT Professionals succeed at work.

convert yyyy-mm-dd to mm/dd/yyyy in php

prashanth ag
prashanth ag asked
Before it was working fine this format getbusinessDays("2015-01-01","2015-12-31",$holidays)

function getbusinessDays($startDate,$endDate,$holidays)
$endDate = strtotime($endDate);                                  
$startDate = strtotime($startDate); before

i want convert  yyyy-mm-dd to mm/dd/yyyy

function getbusinessDays($startDate,$endDate,$holidays)
$endDate = date('mm/dd/yyyy', strtotime($endDate));                  
 $startDate = date('mm/dd/yyyy', strtotime($startDate));

but it shows error
Notice: A non well formed numeric value encountered             (i.,e both lines @$endDate & $startDate)
Watch Question

Full-stack Java Developer
Just try

function getbusinessDays($startDate,$endDate,$holidays)
$endDate = date("m/d/Y", strtotime($endDate));                  
 $startDate = date("m/d/Y", strtotime($startDate));

Open in new window

Most Valuable Expert 2011
Top Expert 2016

We have an article here that answers this question and many more about date / time values.

Going forward, you might want to check the E-E articles, since many of the most common PHP questions are answered there with examples!