-1

When I try to insert date like 20-jan-50 by changing

date("d-m-Y", strtotime($date))

It stores like 20-01-2050. But the actual date was 20-01-1950. After 1980 stores perfect.Like 20-jan-89 was stored as 20-01-1989.

Narendrasingh Sisodia
  • 21,247
  • 6
  • 47
  • 54
Rajesh S
  • 13
  • 1

3 Answers3

2

You need to check Docs. It is clearly noted within that if number of year is specified in a two digit format, the values between 00-69 are mapped to 2000-2069 and 70-99 to 1970-1999

Note: If the number of the year is specified in a two digit format, the values between 00-69 are mapped to 2000-2069 and 70-99 to 1970-1999. See the notes below for possible differences on 32bit systems (possible dates might end on 2038-01-19 03:14:07).

Narendrasingh Sisodia
  • 21,247
  • 6
  • 47
  • 54
1
<?php 

$date="20-jan-50";
$a=date("d-m-y", strtotime($date));
echo $a;

?>

write this code.i hope this work.

  • store your date which want to convert in $date.because y is for display last 2 later of year & Y is for display Full year – Patel Kishan Oct 03 '15 at 12:46
0

you date format is not compatible with strtotime you must use: Year, month and day:

$date = '2050-01-20';
date("Y-m-d", strtotime($date));
Red Acid
  • 217
  • 1
  • 3
  • 14