Jump to content

strtotime and NULL values


bowker

Recommended Posts

Hi hope someone can help, I have a field called DateBooked which by default is NULL.

As expected strtotime brings back 01/01/1970

I am using DateBooked as one of the fields on an email that is being sent automatically.

I need an IF statement to check if DateBooked is NULL and if so return blank and if not return the date as d-m-y.

The code below runs fine to insert the info in the email, I'm just not sure where to put the IF to check DateBooked is NULL or not.

 

function getTrainingHtml($data) {
    $training = '';
    foreach ($data as $value) {
    
        $training .= '
        <tr style="line-height: 25px;">
            <td width="15%" style="border-bottom: 1px solid #ddd;">'.$value['FirstName'].' '.$value['LastName'].'</td>
            <td width="40%" style="border-bottom: 1px solid #ddd;">'.$value['CourseName'].'</td>
            <td width="10%" style="border-bottom: 1px solid #ddd;">'.date('d-m-Y' , strtotime ($value['ExpiryDate'])).'</td>
			<td width="10%" style="border-bottom: 1px solid #ddd;">'.date('d-m-Y' , strtotime ($value['DateBooked'])).'</td>
			<td width="25%" style="border-bottom: 1px solid #ddd;">'.$value['Notes'].'</td>
        </tr>';   
    }
    return $training;
}

function executeQuery($query)

 

Link to comment
Share on other sites

How about this:

	foreach ($data as $value)
{
    if (!is_null($values['DateBooked']))
        $db = date('d-m-y',strtotime($values['DateBooked']));
    else
        $db = '';
    //  Now use $db to output your date booked entry
    $training .= '......

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.