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 |
How to differentiate isset and empty
6 Answers A1 Technology, Dass Infotech, Microface,
How many bootable file in O/S - XP,2000, and 98. which are the files.
What is the difference between mysql_fetch_object and mysql_fetch_array?
Tell me is it possible to remove the html tags from data?
What are the advantages of php?
Tell us what is the difference between session_unregister() and session_unset()?
What IS PHP?
what is the diffrence between for and foreach?
11 Answers Hirolasoft, IBM, Photon,
What is session data?
Tell me what is the meaning of a final class and a final method?
What is the difference between echo and print statement?
11 Answers Rushmore Consultancy,
How would you impletement download and upload a file in php