Jump to content

Help with dates and placement of the strtotime()


CodeMama

Recommended Posts

I need to figure out where the strtotime() goes to parse the date back to a date here is my code ..this is for a search function::

if (!empty($_POST['bmonth']))
    {
    $bmonth = $_POST['bmonth'];
    $_SESSION['bmonth'] = $bmonth;
    $formEmpty = FALSE;
    $bmonth = TRUE;
    }
    else
    {
    $bmonth = '';
    unset($_SESSION['bmonth']);
    $bmonth = FALSE;
    }
    
       if (!empty($_POST['bday']))
    {
    $bday = $_POST['bday'];
    $_SESSION['bday'] = $bday;
    $formEmpty = FALSE;
    $bday = TRUE;
    }
    else
    {
    $bday = '';
    unset($_SESSION['bday']);
    $bday = FALSE;
    }    
     
        if (!empty($_POST['byear']))
    {
    $byear = $_POST['byear'];
    $_SESSION['byear'] = $byear;
    $formEmpty = FALSE;
    $byear = TRUE;
    }
    else
    {
    $byear = '';
    unset($_SESSION['byear']);
    $byear = FALSE;
    }    
    

   $bdate = date("$bmonth/$bday/$byear");    
    
    if($formEmpty)
    {
    // No values were sent through $_POST, so form was empty. Reset $SESSION and redirect back to restaurants.php
    $_SESSION['results'] = NULL;

what about something like off the manual :confused:

 

<?php
$str = 'Not Good';

// previous to PHP 5.1.0 you would compare with -1, instead of false
if (($timestamp = strtotime($str)) === false) {
    echo "The string ($str) is bogus";
} else {
    echo "$str == " . date('l dS \o\f F Y h:i:s A', $timestamp);
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.