Last active
August 29, 2015 14:22
-
-
Save yahyaerturan/dc203b0ee741ced472bf to your computer and use it in GitHub Desktop.
Ajansbu İSTOÇ Üyelik Yenileme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function reformat_datetime ($datetime=null , $target_format = 'Y-m-d H:i:s') { | |
if($datetime) { | |
$date = new DateTime($datetime, new DateTimeZone('Europe/Istanbul')); | |
if($target_format == 'datetime') return $date->format('Y-m-d H:i:s'); | |
else if ($target_format == 'date_tr') return $date->format('d.m.Y'); | |
else if ($target_format == 'time_tr') return $date->format('H:i:s'); | |
else if ($target_format == 'datetime_tr') return $date->format('d.m.Y H:i:s'); | |
else if ($target_format == 'timestamp') return $date->getTimestamp(); | |
else return $date->format($target_format); | |
} else { | |
return $datetime; | |
} | |
} | |
$old = '1431200063'; | |
echo 'old: ' . $old.' | '. date("Y-m-d H:i:s",$old) . '<br/>'; | |
$new_date = date("Y-m-d H:i:s",strtotime("+1 year",$old)); | |
$new_unix = reformat_datetime($new_date,'timestamp'); | |
echo '<hr>'; | |
echo 'new: ' . $new_unix. ' | '. date("Y-m-d H:i:s",$new_unix) .'<br/>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment