Created
March 21, 2013 03:46
-
-
Save norcross/5210538 to your computer and use it in GitHub Desktop.
manipulating the date info for WP_Query
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 | |
// first get two related time settings | |
$zone = get_option('timezone_string'); | |
$gmto = get_option('gmt_offset'); | |
// is it a name based timezone selection? then create the offset | |
if (!empty($zone)) { | |
$zone = new DateTimeZone($zone); | |
$offs = $zone->getOffset(new DateTime); | |
$offs = $offs * -1; | |
// using old school UTC offset? fine then. be that way. | |
} else { | |
$offs = ( ($gmto * 3600) * -1 ); | |
} | |
// get my server time | |
$now = time(); | |
// calculate my offset | |
$stamp = ($now - $offs); | |
// get my integer values | |
$d = date('d', $stamp); | |
$m = date('m', $stamp); | |
$y = date('Y', $stamp); | |
$args = array( | |
'day' => $d, | |
'month' => $m, | |
'year' => $y | |
); | |
$posts = get_posts( $args ); | |
print_r($posts); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment