Working with dates and times in PHP - My own Language (Page 4 of 4 ) 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. <?php $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. <?php 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. About the Author Hermawan Haryanto is a Web Application Developer with over seven years of Website development experience; provide web application development services internationally. Holds the position of IT Director on his own small and fast growth company, dMonster.com, where he is also the primary Web Developer. His knowledge of Web Application extends into PHP, MySQL, ASP, SQL Server, PostgreSQL & JavaScript. | 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. |
|