views:

458

answers:

2

In most locale, the first day of the week is Monday. In the US (and presumably elsewhere), the week starts on Sunday.

How can find out in PHP, for an arbitrary locale, the current setting for the first day of the week (Sunday or Monday)?

Thank you.

+3  A: 

From CLDR's supplemental data:

<firstDay day="mon"  territories="001" />
<firstDay day="fri"  territories="MV" />
<firstDay day="sat"  territories="AF BH DJ DZ EG ER ET IQ IR JO KE KW LY MA OM QA SA SD SO TN YE" />
<firstDay day="sun"  territories="AS AZ BW CA CN FO GE GL GU HK IE IL IN IS JM JP KG KR LA MH MN MO MP MT NZ PH PK SG SY TH TT TW UM US UZ VI ZW" />
<firstDay day="sun"  territories="ET MW NG TJ" draft="unconfirmed" />
<firstDay day="sun"  territories="GB" draft="unconfirmed"  alt="variant" references="Shorter Oxford Dictionary (5th edition, 2002)"/>

(territory 001 is "World")

Jaka Jančar
That's quite useful. Thank you for posting that.
Calvin
A: 

Run this command in the shell (bash or sh or etc):

locale first_weekday

In PHP, call a process to run this command in sh, and get it's output. In Python, I does a thing like this:

def getLocaleFirstWeekDay():
  return int(os.popen('locale first_weekday').read())-1