Saturday, 18 May 2013 13:56

how to extract day,month,year values from date string input in php

Written by 
Rate this item
(1 Vote)

there are many ways to take date input in php.here
is a simple way to take date input as string and
extract the individual parts of the date as day,
month,year values.this values can be used for
different purposes -

suppose you have taken the date input in a form
by the following way using html -

Date of Birth (mm/dd/yy)<br><input type="text"
name="dob" size="8" maxlength="8" class="txt">

after the form have been submitted and dob was
past as POST data,extract the individual parts
of the date.first make use of the explode function
as follows-

array = explode("/", $dob);
$dobmonth = $array[0];
$dobday = $array[1];

if ($array[2] > 80)
$dobyear = "19" . $array[2];

else
$dobyear = "20" . $array[2];
$fdob = "$dobyear-$dobmonth-$dobday";

here the individual parts were extracted
as dobyear,dobmonth,dobday.

Read 8933 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

3 comments

  • Comment Link Super User Sunday, 21 July 2013 12:45 posted by Super User

    @Haley no paid things here, it's free technology tip.You can also submit articles,tips here

  • Comment Link Sunday, 21 July 2013 05:40 posted by Haley

    I'm extremely impressed together with your writing talents as smartly as with the layout for your blog. Is this a paid subject matter or did you customize it your self? Anyway stay up the excellent quality writing, it is uncommon to peer a great weblog like this one nowadays..

  • Comment Link Monday, 08 July 2013 06:16 posted by hNwpHHkqKZ

    hydrocodone hydrocodone apap tablets - hydrocodone vs oxycodone conversion chart

Login to post comments