Skip to content

Instantly share code, notes, and snippets.

@taniarascia
Created November 2, 2015 19:50
Show Gist options
  • Save taniarascia/2305211038259e9cba5e to your computer and use it in GitHub Desktop.
Save taniarascia/2305211038259e9cba5e to your computer and use it in GitHub Desktop.
Pulling date via $_GET from URL, parsing it into strings to be used later
<?php
// No date is set if they didn't click a specific date
$eventDate = false;
// If 'date' is in the URL
if(isset($_GET[date])) {
// Date is set
$eventDate = true;
// Splitting the string to get individual values
$dateString = explode('-',$_GET[date]);
$eventDay = $dateString[0];
$eventMonth = $dateString[1];
$eventYear = $dateString[2];
// The full, textual representation of the date. "F" = November; "j" = 3; "Y" = 2015;
$eventTotal = date("F j, Y",strtotime($_GET[date]));
}
?>
<section id="single">
<?php
<h3><?php the_title(); ?></h3>
<?php if($eventDate == true) { // If the date is set?>
<h4>
<?php echo $eventTotal; // Echo textual representation of date?>
at 10:00pm
</h4>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment