Zaloguj | Zarejestruj | FAQ
Anonymous

Understanding problem

+ Odpowiedz

Posty: 4 Strona 1 z 1


Understanding problem

przez RealEfect » Pt lip 08, 2011 10:07 pm

Kod: Zaznacz cały
function EnglishDateTime($date) {
   
     // Array with the English names of the days of the week
     $arrDay = array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
   
     // Array with the English names of the months
     $arrMonth = array("","January","February","March","April","May","June","July","August","September","October","November","December");
   
     // The date is constructed
     $EnglishDateTime = $arrDay[b][[/b](date("w",[b]$date[/b]))[b]][/b] . ", " . date("d",$date);
     $EnglishDateTime = $EnglishDateTime  . " " . $arrMonth[date("m",$date)] . " " . date(Y,$date);
     $EnglishDateTime = $EnglishDateTime  . ", " . date("H",$date) . ":" . date("i",$date);
   
     return $EnglishDateTime;


Hi, so now i'm learning php and i don't understand these codes which is in bold now.And all others variables named $dates, what it does, can someone say?Also i don't understand these [ ] signs, what it does too?Next problem is in this line:
Kod: Zaznacz cały
echo EnglishDateTime(time());

I don't know for what is time() used?Thanks :)
Avatar użytkownika

RealEfect

  • Posty: 2
  • Dołączył(a): Pt lip 08, 2011 10:03 pm

Re: Understanding problem

przez HTML.net » So lip 09, 2011 7:57 am

$arrDay[] is an array (see http://html.net/tutorials/php/lesson8.php). When you "call" $arrDay[0] it returns "Monday", when you call $arrDay[1] it returns "Tuesday" etc.

In the example the array is called with "date("w",$date)" which will return the day of the week (as a number) for the date $date (see http://html.net/tutorials/php/lesson4.php).

- Andreas, HTML.net
Avatar użytkownika

HTML.net
Site Admin

  • Posty: 1194
  • Dołączył(a): So wrz 11, 2010 11:24 am
--
Show some love for HTML.net on Twitter, Facebook and Google: Use the buttons on top of all pages.

Re: Understanding problem

przez RealEfect » So lip 09, 2011 11:53 am

But why we cannot write only like date("w") and instead of that we need to write date("w",$date).Because i think when we write date("w") it will display day of the week too, isn't that right?And also for what is time() used for?Thank you for the answers! :)
Avatar użytkownika

RealEfect

  • Posty: 2
  • Dołączył(a): Pt lip 08, 2011 10:03 pm

Re: Understanding problem

przez HTML.net » So lip 09, 2011 6:04 pm

That is correct. But this way we can call the function with any date/time ($date) instead of just the current date/time. Does it make sense?

- Andreas, HTML.net
Avatar użytkownika

HTML.net
Site Admin

  • Posty: 1194
  • Dołączył(a): So wrz 11, 2010 11:24 am
--
Show some love for HTML.net on Twitter, Facebook and Google: Use the buttons on top of all pages.


+ Odpowiedz

Strona 1 z 1

cron