how to extract month from given date by using string
functions?
Answers were Sorted based on User's Feedback
Answer / guest
print strftime('%B',time());
This will return the name of the current month.
And date('M') also will return current month.
If you want to get month from the date then use the
following way.
$date=date('d/M/Y')
$date=substr($date,strpos($date,'/')+1);
$date=substr($date,0,strpos($date,'/'));
Finally $date will contain the month name.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / subodh
Assume date is like $datestr = '01-12-2013';
then it can be below two ways:
1. echo date('M', strtotime($datestr)); // for textual
// Or date('m', strtotime($datestr)); // for numeric
2. $list($d, $m, $y) = explode('-', $datestr);
echo $m; // for numeric
Is This Answer Correct ? | 0 Yes | 0 No |
use this code.
[code]
?php
print date ( 'm',mktime ( 0,0,0,02,26,2010 ) ) ;
?>
~
[/code]
Is This Answer Correct ? | 0 Yes | 3 No |
Which have the fastest execution between mysql_fetch_array() and mysql_fetch_assoc()
Tell me will a comparison of an integer 12 and a string "13" work in php?
What is the string concatenation operator in php?
Applications written to provide a GUI shell for Unix and Linux are called
How do you compare strings in java?
How can we check the value of a given variable is a number?
Explain me what is the goto statement useful for?
What is a simple php method to make a cross domain data request?
Tell me what is htaccess?
What is the meaning of a persistent cookie?
What is the $_ server php_self variable?
How to check curl is enabled or not in PHP