Author |
Message |
testy1
Involved
Joined: Apr 06, 2008
Posts: 484
|
Posted:
Thu Jul 31, 2008 4:41 pm |
|
Im working on a module and i keep getting the following php notice.
Code:
Warning: mktime() expects parameter 6 to be long
Notice: Undefined index: 1
Notice: Undefined index: 2
|
the code is as follows
Code:
$time = strftime("%F", mktime($time[4], $time[5], $time[6], $time[2],$ time[3], $time[1]));
$date_array = explode("-", $time);
$timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
$formatted_date = date("F j, Y", $timestamp);
|
so i thought i would check that date_array exists before proceeding
Code:
$time = strftime("%F", mktime($time[4], $time[5], $time[6], $time[2],$ time[3], $time[1]));
$date_array = explode("-", $time);
if (!empty($date_array)) {
$timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
}
$formatted_date = date("F j, Y", $timestamp);
|
but the warning still exists, i have a feeling its php5 related as i dont remember ever having this issue before.
Anyone got any ideas on this. |
|
|
|
|
Raven
Site Admin/Owner
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Thu Jul 31, 2008 6:51 pm |
|
Quote: | $time = strftime("%F", mktime($time[4], $time[5], $time[6], $time[2],$ time[3], $time[1])); |
I'm unable to test this because that code is referencing a $time array but you have not included the code that creates the $time array. Please supply all the needed code.
But, in general, the error seems to be saying that $time[1] is not in a format the strftime() is expecting. |
|
|
|
|
testy1
|
Posted:
Thu Jul 31, 2008 7:42 pm |
|
argh ok forgot about that lol its pulling from the database
Code:
while(list($rating, $timestamp) = $db->sql_fetchrow($result)) {
$comments = stripslashes($comments);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $timestamp, $time);
|
|
|
|
|
|
Raven
|
Posted:
Thu Jul 31, 2008 8:42 pm |
|
Unfortunately that still won't help. It's the data that's the issue. The function is receiving unexpected "type" data. An example would be expecting a date and receiving a string. Try listing out all the timestamps and you will probably see the invaid value somewhere. |
|
|
|
|
testy1
|
Posted:
Thu Jul 31, 2008 11:38 pm |
|
well using var dump on $time before this code
Code:
$time= strftime("%F",mktime($time[4],$time[5],$time[6],$time[2],$time[3],$time[1]));
|
i get
Code:
string(4) "2008"
string(2) "08"
string(2) "01"
string(2) "08"
string(2) "27"
string(2) "03"
|
if i run var dump after the first piece of code i get
Code:
NULL
NULL
NULL
NULL
NULL
NULL
|
so it wouls seem this is the problem
Code:
$time= strftime("%F",mktime($time[4],$time[5],$time[6],$time[2],$time[3],$time[1]));
|
can anyone see anything wrong with it |
|
|
|
|
Raven
|
Posted:
Fri Aug 01, 2008 12:07 am |
|
|
|
|
testy1
|
Posted:
Fri Aug 01, 2008 12:38 am |
|
sorry ive always had trouble with mktime
before it goes through this
Code:
$time= strftime("%F",mktime($time[4],$time[5],$time[6],$time[2],$time[3],$time[1]));
|
its fine but after it outputs.
im still thinking this is php5 related. |
|
|
|
|
Raven
|
Posted:
Fri Aug 01, 2008 12:57 am |
|
What are the values for each of these? They have to form a valid time stamp.
$time[4]
$time[5]
$time[6]
$time[2]
$time[3]
$time[1] |
|
|
|
|
testy1
|
Posted:
Fri Aug 01, 2008 1:11 am |
|
in the same order as you suggested
Code:
string(2) "08"
string(2) "27"
string(2) "03"
string(2) "08"
string(2) "01"
string(4) "2008"
|
|
|
|
|
|
Raven
|
Posted:
Fri Aug 01, 2008 10:51 am |
|
Edited out - I misread your previous post. |
Last edited by Raven on Fri Aug 01, 2008 9:38 pm; edited 1 time in total |
|
|
|
testy1
|
Posted:
Fri Aug 01, 2008 6:07 pm |
|
lol yer but which ones they all seem to be there to me?
i noticeed that since php 5.1 they introduced $is_dst could that be it |
|
|
|
|
Raven
|
Posted:
Fri Aug 01, 2008 9:41 pm |
|
Google for Warning: mktime() expects parameter 6 to be long and read the issues. It could just be you're using a buggy PHP5 release. |
|
|
|
|
selectric
Regular
Joined: Aug 06, 2008
Posts: 65
|
Posted:
Mon Apr 13, 2009 2:34 pm |
|
|
|
|
|