Page 1 of 1

date wrong displayed

Posted: Wed Apr 15, 2009 11:14 am
by ud2008
Script URL: local
Version of script: 2.0
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

Write your message below:

I've been testing this small thing. I've changed (for testing) one of the input fields on the "add ticket" page, from an email input to date input. But I also created a code (copied it from the original) to show only the date and not the time.

Code: Select all

function hesk_datum($dat='')
{
	global $hesk_settings;

    if (!$dat)
    {
    	$dat = time();
    }
    else
    {
    	$dat = strtotime($dat);
    }

	return date($hesk_settings['dateformat'], $dat);
} // End hesk_datum()
This works on the add ticket page (perfect showning the date of today. Add also everything to the database and at other pages).

But when I post the ticket, and watch the ticket I just posted the date is shown as 01-01-1970 and not as today.

At the ticket.php I saw the following line (the default line):

Code: Select all

<tr>
		    <td class="tickettd"><?php echo $hesklang['date']; ?>:</td>
		    <td class="tickettd"><?php echo hesk_date($ticket['dt']); ?></td>
		    </tr>
And this is the code I've placed a couple of lines later (which doesn't work):

Code: Select all

<tr>
		    <td class="tickettd"><?php echo $hesklang['date_deliv']; ?>:</td>
		    <td class="tickettd"><?php echo hesk_datum($ticket['dat']); ?></td>
		    </tr>
Oh btw here is the line I use at the add ticket page (which works):

Code: Select all

<tr>
	<td style="text-align:right" width="150"><?php echo $hesklang['date_deliv']; ?>: <font class="important">*</font></td>
	<td width="80%"><input type="text" name="dat" id="dat" size="15" maxlength="15" value="<?php echo stripslashes(hesk_datum($_SESSION['c_dat']));?>" /></td>
	</tr>
Anybody an idea why it only works on the add ticket page and nowhere else?

Posted: Wed Apr 15, 2009 1:31 pm
by Klemen
01-01-1970 is the default date PHP will return if the input for date() function is wrong (01-01-1970 is the lower limit for the date function).

This means something is wrong with the data you are passing to the date function; what exactly I don't know as I don't see the full picture and also can't provide support on customizations you make. But it "works" on submit a ticket page because the value is just stored and retrieved from a session there (doesn't really "work" because the input hasn't been processed by the date function yet, but it shows what you entered).

Posted: Wed Apr 15, 2009 2:01 pm
by ud2008
Found the solution.

I forgot at the Submit_ticket.php I had the value for the database written as 'NOW()' instead of NOW().

Now it works.

Posted: Wed Apr 15, 2009 2:34 pm
by Klemen
That's exactly why I don't and can't provide support for custom modifications - you didn't even mention the use of NOW() in your post, how can one troubleshoot something if he doesn't have a complete picture of what's going on.

Anyway, glad you found the problem!