Working with Dates and Times in PHP - My own Language
(Page 6 of 6 )
By this time I hope you can create your own date and time using the timestamp of the current date or your own timestamp. I'm not using English as my primary language, and neither are my website users. We are from Indonesia and I want to display the date in Indonesian language. How can I do it? That's a perfect question and asked by most beginners.
Let's create an associative array of date and month in our own language.
$days = Array ("Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jum'at", "Sabtu");
$months = Array (1=>"Januari",
2=>"Pebruari",
3=>"Maret",
4=>"April",
5=>"Mei",
6=>"Juni",
7=>"Juli",
8=>"Agustus",
9=>"September",
10=>"Oktober",
11=>"Nopember",
12=>"Desember");
After we create our own language of date and months, now it's time to display it.
print $days[date("w")]; // display name of day with our own language
print $months[date("n")];
Ok guys, that's it for today. We'll see you again next time.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |