Skip to content

Instantly share code, notes, and snippets.

@yahyaerturan
Last active August 29, 2015 14:22
Show Gist options
  • Save yahyaerturan/dc203b0ee741ced472bf to your computer and use it in GitHub Desktop.
Save yahyaerturan/dc203b0ee741ced472bf to your computer and use it in GitHub Desktop.
Ajansbu İSTOÇ Üyelik Yenileme
<?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