Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

Which is the latest version of php?

0 Answers  


How long does a php session last for?

0 Answers  


What are the string functions in php?

0 Answers  


How to upload any files extension in our database Ex.(.doc,.txt,mp4,mp3 etc.)in php

1 Answers  


Which is variable cost?

0 Answers  






How to read a file in php?

0 Answers  


How can i change the extension name like i have a page which name aboutme.php but i want to show it aboutme.php3 or aboutme.aspx?

3 Answers  


How can we get second of the current time using date function?

2 Answers   FD, IBM,


What is empty () in php?

0 Answers  


What is difference between get and post in php?

0 Answers  


What is the maximum size of a database in mysql?

0 Answers  


How to include variables in double-quoted strings in php?

0 Answers  






Categories