Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeffreyroberts/5313594 to your computer and use it in GitHub Desktop.
Save jeffreyroberts/5313594 to your computer and use it in GitHub Desktop.
<?php
$start_date = strtotime('3 months ago');
$start_quarter = ceil(date('m', $start_date) / 3);
$start_month = ($start_quarter * 3) - 2;
$start_year = date('Y', $start_date);
$start_timestamp = mktime(0, 0, 0, $start_month, 1, $start_year);
echo $start_timestamp;
SELECT UNIX_TIMESTAMP(STR_TO_DATE(CONCAT('1,', ((QUARTER(DATE_SUB(NOW(), INTERVAL 3 MONTH)) * 3) - 2), ',', YEAR(NOW())),'%d,%m,%Y'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment