0

I wanna show my date in my notification

My code PHP as you can see below returns the date without problem

<?php
 require_once  'connexion.php';
$sql = "select dateTraitement from DateTraitement";
$params1 = array();
$options1 =  array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$stmtNew = sqlsrv_query( $conn, $sql , $params1, $options1 );
if( $stmtNew === false) {
    die( print_r( sqlsrv_errors(), true) );
}

    while( $rowNew = sqlsrv_fetch_array( $stmtNew, SQLSRV_FETCH_ASSOC)) {
        $traitementD = $rowNew["dateTraitement"];
         echo  date_format(($traitementD), 'Y/m/d');

    }
?>

To show this I use this code

function traitement() {
  $.ajax({
    url: "datet.php",
    dataType: 'json',
    data: new Date('traitementD'),
    success: function(traitementD) {
      alert('true');

    },
    error: function() {
      alert('false')
    }
  });
}

but when I refresh my webpage it gives me always false

mplungjan
  • 169,008
  • 28
  • 173
  • 236
cte4 stack
  • 41
  • 4
  • Probably because 1. `traitementD` isn't a valid date... Read up on the Date object, w3schools may be better for you.. https://www.w3schools.com/jsref/jsref_obj_date.asp and 2. You are not json_encoding your stuff from `datet.php` – IsThisJavascript Mar 15 '18 at 09:35
  • Missing `date_create`? : `date_format(date_create($traitementD), 'Y/m/d');` – Syscall Mar 15 '18 at 09:38

0 Answers0