Monday, May 13, 2013

How to get date of any language in PHP



Today i'm gonne create a function to get date in any languages



result :
example :
dutch language : maandag 13 mei 2013 - 23:30


<?php

function get_tr_date()
{

$months = array(
    "Jan" => "",//Enter the corresponding January betwen "" and same things for the others months and for days
    "Feb" => "",
    "Mar" => "",
    "Apr" => "",
    "May" => "",
    "Jun" => "",
    "Jul" => "",
    "Aug" => "",
    "Sep" => "",
    "Oct" => "",
    "Nov" => "",
    "Dec" => ""
);
$days=array("Mon" =>" " ,
       "Tue" => "","Wed" => "","Thu" =>"","Fri"=>"","Sat"=>"" ,"Sun"=>""
            );

$your_date = date("Y-m-d"); // for example
$en_day = date("D", strtotime($your_date));
foreach ($days as $en => $tr) {
    if ($en == $en_day) {
        $tr_day = $tr;
    }
}
$en_month = date("M", strtotime($your_date));

foreach ($months as $en => $tr) {
    if ($en == $en_month) {
        $tr_month = $tr;
    }
}

return $tr_day." ".date("y")." ".$tr_month." 2013 - ".date("H:i");

}
echo get_tr_date();

?>






2 comments:

  1. Thanks for sharing this great and informative blog with us, You know I was looking for how to add the date of any language in the blogger but I wasn't able to find any guide like this one. Thanks again mate for sharing this with us. Keep up the great work.

    OptimiZed360 specialize in Pediatric Websites development and marketing. They DO NOT use website templates.

    ReplyDelete
  2. Foxagile Solutions is the best IT service provider company based in Noida heart of India. Established in 2012, we are a strong team of highly experienced IT professionals, they help us in providing website designing, website development and Website development company in India other services in the single window.

    ReplyDelete