web 2.0

How to use PHP & Convert Date/Time

How to use PHP & Convert Date/Time This function will be using PHP and  using function Convert Date/Time

ShotDev Focus:
- PHP & Convert Date/Time

Example

php_date_convert.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?php
function DateThai($strDate)
{
$strYear = date("Y",strtotime($strDate))+543;
$strMonth = date("n",strtotime($strDate));
$strDay = date("j",strtotime($strDate));
$strHour = date("H",strtotime($strDate));
$strMinute = date("i",strtotime($strDate));
$strSeconds = date("s",strtotime($strDate));
$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
$strMonthThai = $strMonthCut[$strMonth];
return "$strDay $strMonthThai $strYear, $strHour:$strMinute";
}

$strDate = "2010-08-14 13:42:44";
echo "Convert to Thai format : ".DateThai($strDate);
?>
</body>
</html>

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_date_convert.php

Screenshot

PHP Convert Date/Time
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.