Status
Not open for further replies.

ElitePirate

Active Member
136
2009
3
80
hi

i use this :

$date_new=$_GET['year']."-".$_GET['month']; from a form and i used to display the value like this :

<b>Captured Date :</b> <?php echo $date_new; ?>

Its working fine, how ever the output it like = 2013-01. I want it to be 2013-Jan

How can i use dateformat in this code?

Thanks
 
5 comments
If you're using $_GET to pass data to your script, and echo it like you are, you're opening yourself up to a world of exploitation. $_GET['month'] could be tainted with JavaScript and/or a crafty image/iframe hack allowing for cross scripting. I hope there's some form of validation before this code is reached.

All that aside, use mktime to create a timestamp and date to form the abbreviated representation of the month.

Code:
$month = date( 'M', mktime( 0, 0, 0, $_GET[ 'month' ], 10 ) );

$date_new = $_GET['year'] . "-" . $month; 

<b>Captured Date :</b> <?php echo $date_new; ?>

Should work.
 
Status
Not open for further replies.
Back
Top