how to extract month from given date by using string
functions?

Answers were Sorted based on User's Feedback



how to extract month from given date by using string functions?..

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

how to extract month from given date by using string functions?..

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

how to extract month from given date by using string functions?..

Answer / pavunkumar

use this code.


[code]
?php
print date ( 'm',mktime ( 0,0,0,02,26,2010 ) ) ;
?>
~
[/code]

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More PHP Interview Questions

Write down the code for save an uploaded file using php?

0 Answers  


How to create a web form?

0 Answers  


I have two radio button, i click one radio button display one dropdown box, one text field. and then click another radio button display one text field.so any one give me good idea plz.....i used <div id="" style=display:none> but not work..

4 Answers  


what are interfaces and Abstart classes

0 Answers   Net Solution,


What is the alternative structure for control structures?

0 Answers  






Explain me how to include a file to a php page?

0 Answers  


How to remove an empty directory?

0 Answers  


What is regular expression in php?

0 Answers  


What are php variables?

0 Answers  


How can you get, the total size of a certain directory?

1 Answers  


Which function you can use in php to open a file for reading or writing or for both?

0 Answers  


Are react hooks stable?

0 Answers  


Categories