Skip to content

Instantly share code, notes, and snippets.

@diloabininyeri
Last active March 11, 2020 11:30
Show Gist options
  • Save diloabininyeri/daca3acabde8f639fe7314de45ab02ce to your computer and use it in GitHub Desktop.
Save diloabininyeri/daca3acabde8f639fe7314de45ab02ce to your computer and use it in GitHub Desktop.
<?php
/**
*@author dılo sürücü
*
*/
$time=[
'y'=>'sene',
'm'=>'ay',
'd'=>'gün',
'h'=>'saat',
'i'=>'dakika',
's'=>'saniye'
];
$date=new DateTime('now');
$date1=new DateTime('2020-01-3');
$difference=$date->diff($date1);
$flag= array_search(!0,(array)$difference);
if($date>$date1)
echo $difference->format("%$flag $time[$flag] önce"); //7 sene önce
else
echo $difference->format("%$flag $time[$flag] sonra"); //7 sene sonra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment