Splite Text/date in PHP

Dear Expert,

How can I splite date as below?
<input type="text" name="daterange" value="2015-04-01 - 2015-06-30"/>
if (isset($_POST['submit'])) {
    $daterange = $_POST['daterange'];

Open in new window

I want to have two variable get value from "daterange" as below:

one more thing after split, I want to add some text to it.

$fulldatestart='2015-04-01 00:00:00:000';
$fulldateend='2015-06-30 00:00:00:000';
arkam chouAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello, you can use the explode or substr commands.  Substr may be better suited if the date will always be in the YYYY-MM-DD format which means always 10 characters.

$daterange = $_POST['daterange'];
$startdate = substr($daterange,0,10);
$enddate = substr($daterange,-10);

Open in new window

With explode, you would need a unique delimiter, so if you were willing to change the input value to have a unique character such as a space between the two dates, that could be used.

<input value="2015-04-01 2015-06-30">
$daterange = $_POST['daterange'];

$dates = explode(" ", $daterange);
$startdate = $dates[0];
$enddate = $dates[1];

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
You should know that PHP's Date function does not support milliseconds, the last 3 000 in your text above.  http://php.net/manual/en/function.date.php
arkam chouAuthor Commented:
I had complete it with your help as below
$daterange = $_POST['daterange'];
$fulldatestart= substr($daterange,0,10)." 00:00:00:000";
$fulldateend= substr($daterange,-10)." 00:00:00:000";

Open in new window

I need like this for another purpose.
Thanks you all.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.