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

A company named Pensar Technologies in chennai has offered me a job as Software Trainee in chennai.But they are asking to pay demand draft of Rs.75000/- in the name of the company.They are saying the gross renumeration will pay Rs.90000/- annually.I want to know whether this is good or bad company?Help me out in this.

18 Answers  


What is .htaccessfile and use of this file

5 Answers  


What is php and why it is used?

0 Answers  


What is the difference between unset and unlink?

0 Answers  


Is age an interval or ratio?

0 Answers  






What are majic methords in php?

0 Answers  


What are the differences between php3 and php4 and php5? What is the current stable version of php? What advance thing in php7?

0 Answers  


What is faster?

0 Answers  


What is the difference between html and php?

0 Answers  


What is the purpose of destructor ?

2 Answers  


How to find the index of an element in an array php?

0 Answers  


what is abstrac class? why it is use?

5 Answers  


Categories