# Understanding problem

Page 1 of 1

## Understanding problem

by RealEfect » Fri Jul 08, 2011 10:07 pm

Code: Select all
`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:
Code: Select all
`echo EnglishDateTime(time());`

I don't know for what is time() used?Thanks :)

RealEfect

• Posts: 2
• Joined: Fri Jul 08, 2011 10:03 pm

## Re: Understanding problem

by HTML.net » Sat Jul 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

HTML.net

• Posts: 1184
• Joined: Sat Sep 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

by RealEfect » Sat Jul 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! :)

RealEfect

• Posts: 2
• Joined: Fri Jul 08, 2011 10:03 pm

## Re: Understanding problem

by HTML.net » Sat Jul 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

HTML.net

• Posts: 1184
• Joined: Sat Sep 11, 2010 11:24 am
--
Show some love for HTML.net on Twitter, Facebook and Google: Use the buttons on top of all pages.

vergar
Online

• Posts: 264043
• Joined: Tue Apr 16, 2019 2:34 pm

vergar
Online

• Posts: 264043
• Joined: Tue Apr 16, 2019 2:34 pm

vergar
Online

• Posts: 264043
• Joined: Tue Apr 16, 2019 2:34 pm

vergar
Online

• Posts: 264043
• Joined: Tue Apr 16, 2019 2:34 pm

vergar
Online

• Posts: 264043
• Joined: Tue Apr 16, 2019 2:34 pm

vergar
Online

• Posts: 264043
• Joined: Tue Apr 16, 2019 2:34 pm