.


Divya

How to split date in PHP MVC with example


In this example we using only a Controller file for upload split date.

Here is the Controller file hello.php which inside controllers folder

controllers/hello.php

Example 1

<?php
class Hello extends Controller {

	function __construct() {
		parent::__construct();
	}
	
	function split_date_2(){
		$orderdate="23-10-2017";
		$orderdate = explode('-', $orderdate);
		$day = $orderdate[1];
		$month = $orderdate[0];
		$year = $orderdate[2];
		echo $day."";
		echo $month."";
		echo $year;
	}
	
}
?>

Example 2

<?php
class Hello extends Controller {

	function __construct() {
		parent::__construct();
	}
	function split_date(){
		$orderdate="23/10/2017";
		$orderdate = explode('/', $orderdate);
		$day = $orderdate[1];
		$month = $orderdate[0];
		$year = $orderdate[2];
		echo $day."";
		echo $month."";
		echo $year;
	}
	
	
}
?>
Path: localhost/project_folder_name/view_folder_name/view_filename Example: localhost/mvc/hello/split_date

.