从MySQL DB中检索出生DATE数据

时间:2016-05-03 08:09:07

标签: php mysql

我正在尝试从mysql DB中检索日期数据。但它返回N / A,即使它不为空。但是当我评论第二个If(声明)它返回1970年1月1日,但实际数据是1952年6月6日.BusDateHired和DateOfBirth 在同一张桌子里。会员日期非常好,它从数据库中检索实际数据。

# GET MEMBERS INFO.
$meminfo_sql = sqlCLIENTINFO($clientid, $br_code);
$meminfo_query = mysql_query($meminfo_sql) or die("ERROR GETTING MEMBER'S DATA".mysql_error());
$meminfo_data = mysql_fetch_array($meminfo_query);


# SET variables for members data.
$fullname = $meminfo_data['LName'].", ".$meminfo_data['FName']." ".$meminfo_data['MName'];
$temp_dateHired= explode("-", $meminfo_data['BusDateHired']);
$temp_dateopened = explode("-", $meminfo_data['DateOpened']);
$temp_birthDate= explode("-", $meminfo_data['DateOfBirth']);

# Date of Birth
$meminfo_birthDate= "";
    if($meminfo_data['DateOfBirth'] != "No Data" || $meminfo_data['DateOfBirth'] != null || !is_null($meminfo_data['DateOfBirth'])){
$meminfo_birthDate = date("F d, Y", mktime(0,0,0,$temp_birthDate[1],$temp_birthDate[2],$temp_birthDate[0])); # date format January 01, 2013
}
#end of Date of Birth

# Date of hired..
$meminfo_dateHired= "";
if($meminfo_data['BusDateHired'] != "No Data"){
    $meminfo_dateHired = date("F d, Y", mktime(0,0,0,$temp_dateHired[1],$temp_dateHired[2],$temp_dateHired[0])); # date-format January 01, 2013
}
if (is_null($meminfo_data['BusDateHired'])) {
   $meminfo_dateHired = 'N/A';
}
# end of Date of hired

1 个答案:

答案 0 :(得分:0)

$meminfo_birthDate= "";
if($meminfo_data['DateOfBirth'] != "No Data" || $meminfo_data['DateOfBirth'] != null || !is_null($meminfo_data['DateOfBirth'])){
  $meminfo_birthDate = date("F d, Y", mktime(0,0,0,$temp_birthDate[1],$temp_birthDate[2],$temp_birthDate[0])); # date format January 01, 2013
}

我已经在线尝试了您的代码,并且演示日期工作正常。

echo date("F d, Y",mktime(0,0,0,02,03,2015));

输出:

February 03, 2015

在线演示Click Here