SQL datetime을 Y/m/d G : i : s 형식으로 변환하려고합니다. ... 그것은 형식의, 그러나 모든 FRONTSLASH의 앞에 백 슬래시가 ... 내가 않는 str_replace와 위해서 stripslashes와 일한 이들의 비를 시도했습니다날짜에서 백 슬래시 제거
데이터 : http://www.zewde.org/instagram/script_new/data.php
코드 :
<?php
define('DB_NAME', 'FollowersCount');
define('DB_USER', '******');
define('DB_PASSWORD', '******');
define('DB_HOST', '*.*.*.*');
$connection = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$connection) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("FollowersCount", $connection);
$sth = mysql_query("SELECT Date FROM Count ORDER BY Date");
$sthh = mysql_query("SELECT Count FROM Count ORDER BY Date");
$sthhh = mysql_query("select a.ID, a.Count,coalesce(a.Count -(select b.Count from Count b where b.ID = a.ID - 1), 5) as diff from Count a ORDER BY Date");
$rows = array();
while(($r = mysql_fetch_array($sth)) && ($rr = mysql_fetch_array($sthh)) && $rrr = mysql_fetch_array($sthhh))
{
$temp_count = intval($rr['Count']);
$temp_date1 = $r['Date'];
$myFormatForView = date("Y/m/d G:i:s", strtotime($temp_date1));
$final = str_replace("\\", "", $myFormatForView); //Doesn't work, neither does stripslashes...
$temp = array($final, $temp_count);
$temp_s = implode(", ", $temp);
$rows['data'][][] = $temp_s;
}
$result = array();
array_push($result,$rows);
$Jz = json_encode($result, JSON_NUMERIC_CHECK);
echo $Jz;
mysql_close($connection);
?>
에 대한 here를 참조하십시오. '\ /'는 JSON 문자열에'/'를 어떻게 표현 하는지를 나타냅니다. 데이터에는''\''이 없으며, 그것은 단지 인코딩 일뿐입니다. – Quentin
그리고 stackoverflow에, 그것을 편집해도 도움이되지 않습니다, 아직 거기에 있습니다. 비밀 번호를 변경하고 질문을 완전히 삭제하도록 모드를 요청하십시오! – baao
도움을 주셔서 감사합니다. tkausl의 대답은 맞습니다. – Lofty