Author Topic: Probs with VDATE  (Read 970 times)

0 Members and 1 Guest are viewing this topic.

darren-m

  • Guest
Probs with VDATE
on: Thu, 20. June 2002 - 16:30:00
Hi all,

Using VLIB, very nice, i have a minor problem, i am using the $date->addInterval function and i believe that my dates are formatted correctly. 2002-06-02 but i keep getting an error Fatal error: vlibDate error: Invalid timstamp used. in /home/www/htdocs/phpnuke/html/includes/vlibDate/error.php on line 52.

Is this a bug or am i doing something wrong.

Here is my exact function call :


$nextweek = $date->addInterval($last_used_date, $date_inc);

where $last_used_date = 2002-06-02
$date_inc = 7 DAYS

Help please.

Darren

releasedj

  • Guest
Probs with VDATE
Reply #1 on: Thu, 20. June 2002 - 16:59:00
The code you've given me seems to work.

I've created a page to show you the code here.

Kind regards,

Kelvin

darren-m

  • Guest
Probs with VDATE
Reply #2 on: Thu, 20. June 2002 - 17:28:00
Hi mate,

Thanks for a very very quick reply. I will have a go and let you know. I cant really see where i am going wrong.

function generate($start_date, $end_date, $date_inc){
$last_used_date=$start_date;



// here are specific vars

$last_used_date = '2002-06-02';
$date_inc = '7 DAYS';


$date = new vlibDate();

$newdate = $date->addInterval($last_used_date, $date_inc);

echo "New date is: ".$date->formatDate($newdate, '%A %d%s %B %Y');




/*
// we need to convert our dates into a VLIB timestamp which is YYYY-MM-DD format
list ($day, $month, $year) = split ('[/.-]', $start_date);
$y = "".$year."/".$month."/".$day."";
$x_start_date = $y;

list ($day, $month, $year) = split ('[/.-]', $end_date);
$y = "".$year."/".$month."/".$day."";
$x_end_date = $y;
$x_end_date = strtotime($x_end_date);



print $start_date;
print "<BR>";
print $end_date;
print "<BR>";
print "<BR>";

$last_used_date = $x_start_date; // set our start date for first iterate
$last_used_date = strtotime($last_used_date);


 $date_inc.= " DAY";
print "The new data is ".$last_used_date."<BR>";
print "The new data is ".$last_used_date."<BR>";

*/

print strrev($last_used_date);
print "<BR>";
print $end_date;
print "<BR>";

while ($last_used_date < $end_date){
$last_used_date = getnewdate($last_used_date,$date_inc);

print $last_used_date;

}

//$x = getnewdate($last_used_date,$date_inc);




}


function getnewdate($last_used_date,$date_inc){
$date = new vlibDate ('en');

 $nextweek = $date->addInterval($last_used_date, $date_inc);

}

releasedj

  • Guest
Probs with VDATE
Reply #3 on: Fri, 21. June 2002 - 11:59:00
Try echo()'ing your timestamp just before you pass it to vlibDate.

This should tell you if it's the correct format, if it's not, I'll try to reproduce the error.

I tested the above code and it seems that the value being passed to the addInterval() function is in dd/mm/yyyy format when it should be in yyyy-mm-dd format.

Kelvin