Problem displaying correct year with values from database

51 views
Skip to first unread message

Atanas - Bulgaria

unread,
Mar 7, 2017, 3:54:17 AM3/7/17
to bootstrap-datepicker
### Expected behaviour
I need when change the date the year to be in numbers like this. 2017-03-06

### Actual behaviour
Now when i change the date the field is filled with this pattern: YY-03-06
And that is happened only if i use values from database.
/I tryed with format: yyyy-mm-dd, but the datepicker reset the date and show year 1911/

### Datepicker version used
1.7.0-RC1

### Example code
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Редакция на запис</title>


</head>
<body>
<?php
   error_reporting(E_ALL); ini_set('display_errors', 1);

 require_once("dbconn.php");

if(isset($_GET['id']))
{
$id=$_GET['id'];

$result = $pdo->prepare("SELECT EU_Fuel_Price.id, 
convert(VARCHAR(24),manual_datetime,113) as manual_datetime,EU_Fuel_Price.company_name,EU_Fuel_Price.country,EU_Fuel_Price.town,EU_Fuel_Price.price,db_countries.idcountry,db_countries.country_name as countryname FROM EU_Fuel_Price INNER JOIN db_countries ON EU_Fuel_Price.id=db_countries.idcountry WHERE EU_Fuel_Price.id = :id");
$result->bindParam(':id', $id, PDO::PARAM_STR);
$result->execute();
while($row=$result->fetch(PDO::FETCH_ASSOC)){
?>
<div class="form-group">
    <label for="manual_datetime" class="col-sm-2 control-label">Дата събитие</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="dateprice" name="dateprice" value="<?php echo $row['manual_datetime']; ?>">
    </div>
  </div>
 <?php
}
}
?>
<script>
$('#dateprice').datepicker({ 
    format: "yyyy-mm-dd",
    todayBtn: "linked",
    clearBtn: true,
    language: "bg",
    orientation: "bottom auto",
    todayHighlight: true
});
</script>
</body>
</html>
Reply all
Reply to author
Forward
0 new messages