bux23
7/19/2016 - 11:37 AM

PHP reverse date format mysql

PHP reverse date format mysql

	$con = mysqli_connect($servername, $username, $password, $dbname) or die();	
	
	$sql = "SELECT * FROM leadz_old";
	
	$fields = mysqli_query($con,$sql);
	while($row = mysqli_fetch_array($fields)){
		echo "changing field... ";
		$theid = $row['id'];
		$thedate = $row['data'];
		$thefirst = $row['first_view'];
		$newfirst = implode("-", array_reverse(explode("-", $thefirst)));
		$newDate = implode("-", array_reverse(explode("-", $thedate)));
		$sql2 = "UPDATE leadz_old SET data='$newDate',first_view='$newfirst' WHERE id=$theid";
		if(mysqli_query($con,$sql2)){
			echo "Field changed! <br />";
		} 
	}