Skip to content

Instantly share code, notes, and snippets.

@subrotoice
Last active January 30, 2023 14:09
Show Gist options
  • Save subrotoice/d820863ce65eb0d8434a47a76d005df4 to your computer and use it in GitHub Desktop.
Save subrotoice/d820863ce65eb0d8434a47a76d005df4 to your computer and use it in GitHub Desktop.
# Convert One date format to another ( Y, m, d, H all meaning w3schools.com/php/func_date_date.asp )
$new_date_format = date('Y-m-d H:i:s', strtotime('2008-07-01T22:35:17.02'));
$oldFormat = "18:30:30 Feb 28, 2008 PST"; // PayPal Format
$newFormat = date('Y-m-d', strtotime($oldFormat) );
# One year add, and time difference
$date1=date_create("2013-03-15"); // $dateStr1=date( 'Y-m-d', strtotime('-1 year') ); $date1 = date_create( $dateStr1 );
$date2=date_create("2013-12-12"); // $dateStr2=date( 'Y-m-d', strtotime('-1 year') ); $date2 = date_create( $dateStr2 );
$diff=date_diff($date1,$date2); // $date1, $date2 must be a PHP date Object
$nextPaymentDate = date('Y-m-d', strtotime($paymentDate . "+2 months") );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment