<tr>
<td><label class="labeldisplay"><?php $regbegdate = $row['RegBegDate'];
echo "Beg Date: " . $regbegdate . "<BR><BR>";
$regenddate = $row['RegEndDate'];
echo "End Date: " . $regenddate . "<BR><BR>"
echo "Travel Beg Date:</label><span style=background-color:yellow><label class='labeldata'>" .
$regbegdate . " TO " . $regbegdate;
?></label></span></td>
<tr>
echo "End Date: " . $regenddate . "<BR><BR>";
error_reporting(E_ERROR | E_PARSE | E_NOTICE);
<td><label class="labeldisplay"><?php $birth = $row['CertifiedBirthCert'];
$result = get_chkbox($birth);
echo "State Certified Birth Certificate Req:</label><span style=background-color:yellow><label class='labeldata'>" .
$result; ?></label></span></td>
</tr>
<tr>
<td><label class="labeldisplay"><?php
var_dump($row['RegBegDate']);
$regbegdate = $row['RegBegDate'];
var_dump($regbegdate);
echo "Beginning Date: " . $regbegdate . "<BR><BR>";
var_dump($row['RegEndDate']);
$regenddate = $row['RegEndDate'];
echo "End Date: " . $regenddate . "<BR><BR>";
echo "Beg Date:</label><span style=background-color:yellow><label class='labeldata'>" . $regbegdate . " TO " . $regbegdate;
?></label></span></td>
</tr>
<td><label class="labeldisplay"><?php
echo "Final Destination:</label><span style=background-color:yellow><label class='labeldata'>" .
$row['FinalDestination'];?></label></span></td>
</tr>
<tr><td></td></tr>
<tr><td></td></tr>
</table>
select *, LEFT(CONVERT(nvarchar,BldInfo.RegBegDate,120), 10) as RegBegDate,
LEFT(CONVERT(nvarchar,BldInfo.RegEndDate,120), 10) as RegEndDate
from BldInfo where BldingId = 'P09'
]
$trvbegdate = date("m-d-Y", strtotime($row['RegBegDate']));
$dateDE = $row['RegBegDate'];
$dateObj = DateTime::createFromFormat("Y-m-d", $dateDE);
$trvlbegdate = $dateObj->format("m/d/Y");
$trvlbegdate = date('m/d/Y',strtotime($trvlbegdate));
Microsoft SQL has about 5 different date formats and I don't 'strtotime' will handle all of them.You can specify how the date comes out in the query. You output it in a format strtotime understands and use date() to get the desired result.
SELECT convert(varchar, RegBegDate, 120) from table
2016-02-02 14:04:03
$date = date('YMD', strtotime($date);
var_dump($row['RegBegDate']);
RegBegDate RegEndDate
2012-02-18 00:00:00.000 2012-02-24 00:00:00.000
Better things to wonder about huh?Because your var_dump was inside a container that clipped the results.
public 'date' string => '2012-02-18 00:00:00' (length = 19)
The length cannot be 19 if there is a .000 on the end ...
<?php // demo/temp_overthere.php
/**
* http://www.experts-exchange.com/questions/28922954/PHP-and-extracting-date-columns-from-MS-SQL-Server.html#a41448385
*
* A good thing to know (make a Google search) "SSCCE"
*/
error_reporting(E_ALL);
// STRLEN: 1...5...10...15...20...25 LOOKS LIKE IT IS 23, NOT 19
// | |
// V V
$ReqBegDate = '2012-02-18 00:00:00.000';
$reqEndDate = '2012-02-24 00:00:00.000';
$ts = strtotime($ReqBegDate);
var_dump($ts);
$is = date('c', $ts);
var_dump($is);
You may also want to use var_dump($row) before you start using any of the contents of $row. This will let you see what might be in the array, or whether $row is, in fact, an array. It might not be. A query failure might have returned FALSE in $row instead of an array of query results.
If you're new to PHP and want some good learning resources, this article may be helpful:
https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html