Error PHP Date Format

I have data date_born with datatype date in table employees with value is 1965-10-08 but in PHP showing 2065-10-08

when I call the date_bord with $employee->date_born it showed 10/08/65

in edit page
image

in view page
image

I realized that php date Year under 1970 shows 2069 and it should be 1969 but if the year is more than 1969 looks normal

for a while, I’m using this code to solve

<?php
         $dateString = $employee->date_born;

         $dateTime = DateTime::createFromFormat('n/j/y', $dateString);

         $year = (int) $dateTime->format('y');

         if ($year >= 55) {
              $date_born = $dateString->format('19y-m-d');

         } else {
              $date_born = $dateString->format('20y-m-d');
         }
?>
<b>Date born: </b> <a class="float-right"><?= $date_born ?></a>

Can you show us the output of running describe employees; in MySQL?

tanggal_lahir mean date_born

That looks fine. I wonder if you’ve got something configured somewhere that’s altering how it’s parsing date strings, due to locale or the like. You shouldn’t need to jump through all the hoops you’re doing to get to a formatted date. What does $employee->date_born->year give you? $employee->date_born->format('Y-m-d')?

thank you it works with this
$employee->date_born->format(‘Y-m-d’)

before I use this $this->tgl_indo(date_format(date_create($employee->date_born), ‘Y-m-d’))
that tgl_indo is the function to make format date in my country
so I change to $this->tgl_indo($employee->date_born->format(‘Y-m-d’))

One of this function probably use Unix timestamp, check this, for the future: