1 2013-10-13 05:27:01 (edited by tovic 2013-10-13 17:29:07)

Topic: Change Date Format/Language to Your Local Format/Language

Before: 17-12-2013

/* plugins/blog/views/frontend/index.view.php */
<?php foreach($posts as $post) { ?>
    <h2 class="date-header"><?php echo Date::format($post['date'], 'd-m-Y'); ?></h2>
<?php } ?>

After: Selasa, 17 Desember 2013

<?php foreach($posts as $post) { ?>
    <?php
        $day = Date::format($post['date'], 'l'); // `Sunday`, `Monday` etc...
        $month = Date::format($post['date'], 'm'); // 01, 02, 03 ...
        switch ($day) {
            case "Sunday":
                $day = "Minggu";
                break;
            case "Monday":
                $day = "Senin";
                break;
            case "Tuesday":
                $day = "Selasa";
                break;
            case "Wednesday":
                $day = "Rabu";
                break;
            case "Thursday":
                $day = "Kamis";
                break;
            case "Friday":
                $day = "Jumat";
                break;
            case "Saturday":
                $day = "Sabtu";
                break;
        }
        switch ($month) {
            case "01":
                $month = "Januari";
                break;
            case "02":
                $month = "Februari";
                break;
            case "03":
                $month = "Maret";
                break;
            case "04":
                $month = "April";
                break;
            case "05":
                $month = "Mei";
                break;
            case "06":
                $month = "Juni";
                break;
            case "07":
                $month = "Juli";
                break;
            case "08":
                $month = "Agustus";
                break;
            case "09":
                $month = "September";
                break;
            case "10":
                $month = "Oktober";
                break;
            case "11":
                $month = "November";
                break;
            case "12":
                $month = "Desember";
                break;
        }
    ?>
    <h2 class="date-header"><?php echo $day . ', ' . Date::format($post['date'], 'd') . ' ' . $month . ' ' . Date::format($post['date'], 'Y'); ?></h2>
<?php } ?>
XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

Re: Change Date Format/Language to Your Local Format/Language

nice, good job big_smile

I'm not like them but I can pretend.