By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,375 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,375 IT Pros & Developers. It's quick & easy.

having a problem with error message whilst using date/time function

anfetienne
100+
P: 424
Hi,

I found a nice piece of code for the date and time and it allows for daylight savings, I have been using this code for a while and i've never had any error messages but for some reason I get a error message now but the function still does what it should.

can anyone see what the problem is?

this is the output from the php page
Warning: Missing argument 3 for zonedate(), called in /home/veresour/public_html/streammii.com/q/dateTest.php on line 17 and defined in /home/veresour/public_html/streammii.com/q/dateTest.php on line 2

Warning: Missing argument 4 for zonedate(), called in /home/veresour/public_html/streammii.com/q/dateTest.php on line 17 and defined in /home/veresour/public_html/streammii.com/q/dateTest.php on line 2

16 Jul 2010 11:52:54
and this is the code
Expand|Select|Wrap|Line Numbers
  1. <?
  2. function zonedate($layout, $countryzone, $daylightsaving, $time)
  3. {
  4.     if($daylightsaving) {
  5.          $daylight_saving = date('I');
  6.         if($daylight_saving){ $zone=3600*($countryzone+1); }
  7.     }
  8.     else {
  9.         if( $countryzone>>0){ $zone=3600*$countryzone; }
  10.             else { $zone=0; }
  11.     }
  12.     if(!$time) { $time = time(); }
  13.     $date = gmdate($layout, $time + $zone);
  14.     return $date;
  15. }
  16.  
  17. $dateAdded = zonedate('d M Y H:i:s',true);
  18.  
  19. echo '<br/>'.$dateAdded;
  20.  
  21.  
  22.  
  23. ?>
  24.  
Jul 16 '10 #1

✓ answered by code green

You are only passing two parameters to a function that expects four.
If you are only using the first two then modify the function to
Expand|Select|Wrap|Line Numbers
  1. function zonedate($layout, $countryzone, $daylightsaving=true, $time=0) 
  2.  
Which means by default, daylight saving will always be applied and system time will be used.

Share this Question
Share on Google+
2 Replies


code green
Expert 100+
P: 1,726
You are only passing two parameters to a function that expects four.
If you are only using the first two then modify the function to
Expand|Select|Wrap|Line Numbers
  1. function zonedate($layout, $countryzone, $daylightsaving=true, $time=0) 
  2.  
Which means by default, daylight saving will always be applied and system time will be used.
Jul 16 '10 #2

anfetienne
100+
P: 424
works like a charm... thank you for your help! once i've finished my project i'll be posting a link so everyone can see what the help was all for

always appreciated
Jul 16 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.