|
|
|
|
|
|
|
sarahA
|
 |
« Reply #3 on: January 10, 2008, 09:42:22 PM » |
|
is there a line number with the error and if so what code is on that line, plus the line before and after. mktime() is a function that i think can be used as mktime() and that will give the time as a unix timestamp (number of seconds since 1st Jan 1970), it can also accept parameters.
Need to see the code before I can say what the problem is though.
|
|
|
|
|
Logged
|
|
|
|
robbie
|
 |
« Reply #4 on: January 10, 2008, 10:04:51 PM » |
|
is there a line number with the error and if so what code is on that line, plus the line before and after. mktime() is a function that i think can be used as mktime() and that will give the time as a unix timestamp (number of seconds since 1st Jan 1970), it can also accept parameters.
Need to see the code before I can say what the problem is though.
Yep, it's on line 56 which is the last line of code in this bit... function formatMySQLDate($inDate) { //get elements of datetime $arr0 = explode(" ", $inDate); $arr1 = explode("-", $arr0[0]); $arr2 = explode(":", $arr0[1]); //reformat elements return date("d M Y", mktime($arr2[0], $arr2[1], $arr2[2], $arr1[1], $arr1[2], $arr1[0])); } Also, when I get the error, I'm getting a date output of 01 Jan 1970 Thanks Sarah
|
|
|
|
|
Logged
|
|
|
|
|
|
robbie
|
 |
« Reply #6 on: January 10, 2008, 10:16:47 PM » |
|
Can you check that none of your input variables is returning zero?
sorry, what do you mean? (Liking your correct use of 'is' with 'none' by the way) 
|
|
|
|
|
Logged
|
|
|
|
|
|
JasonD
|
 |
« Reply #8 on: January 10, 2008, 10:45:07 PM » |
|
mktime() isn't depreciated, only the is_dst param. You have a null value in your database, you probably want to track down where the null is and set it to an appropriate value. And also consider some better code, no errors, and presumably today's date for null values is better than 1970. function formatMySQLDate($inDate) { if ($inDate === null) { return date('d M Y'); } else { return date('d M Y', strtotime($inDate)); } }
|
|
|
|
|
Logged
|
|
|
|
robbie
|
 |
« Reply #9 on: January 10, 2008, 10:49:53 PM » |
|
You have a null value in your database, you probably want to track down where the null is and set it to an appropriate value.
Sorry, I really have no idea what I'm doing. Someone else set this up for me, I can't get hold of him, and I really need to get it solved by the morning. What does it actaully mean that I have a null value in my database.
|
|
|
|
|
Logged
|
|
|
|
|
sarahA
|
 |
« Reply #10 on: January 10, 2008, 10:58:36 PM » |
|
null = empty/zero. mktime expects to receive the following
mktime(hours, minutes, seconds, month, day, year).
So at present one of these is being given as an empty value and killing the script.
Replace the code you posted with Jason's code, that's a good start. Then you'll need to look in the database at what you're trying to retrieve, look at the date field and see if it's correct. Looking at your code it should be in the format of YYYY-MM-DD HH:MM:SS but the record that you're requesting, or one of the records will have something that doesn't match this format, perhaps will even be empty, which may be the most likely cause.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
sarahA
|
 |
« Reply #12 on: January 10, 2008, 11:12:45 PM » |
|
Not necessarily it. There's still a problem with the date being retrieved. Jason's code just ensures no error displays on the website. If no date is retrieved, today's date is displayed. So you still need to investigate the db table where the records are stored and look at the datetime field and see what's going on there. Or get whoever set it up to take a look if you can.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
sarahA
|
 |
« Reply #14 on: January 10, 2008, 11:37:06 PM » |
|
Your function that you originally posted expected a date and time in the value provided to it. So even though you're just setting the day month and year, I can only presume that the field is storing the time perhaps as 00:00:00. However that's just a guess. But yes, if you're in charge of adding a date then i guess the day, month or year wasn't set at some point and so the value hasn't gone in correctly, or at all.
If this came up when viewing a specific product then you'll need to check on the details either via your admin or in the database via phpmyadmin. If it was on a results page for example, then you'll need to check all recently added products if this is only a recent problem.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
|
|
|
|