Split date string in PHP

Jimmy Wales Reply 11:56
split - Split string into array by regular expression

for Example :
Parse a Date which may b delimited with dots, hypens or slashes-

<?php
//store your date in $date variable
$date = "04-24-2014";
list($month, $day, $year) = split('[/.-]', $date);
echo "Month: $month; Day: $day; Year: $year<br />\n";
?>

2nd Example :-

<?php
//store your date in $date variable
$date = "04-24-2014";
list($month, $day, $year) = split('[/.-]', $date);

//  - convert number to month name
$monthNum  = $month;
$monthName = date('F', mktime(0, 0, 0, $monthNum, 10)); // March
echo $monthName .' '.$day .', '. $year ;
?>






Related Posts

split 3891224019626554204
Copyright by GhostPHP. Powered by Blogger.

Search

Recent Post

Popular Posts

Follow us