Jump to content

Archived

This topic is now archived and is closed to further replies.

klinmy

extract month of date

Recommended Posts

i would like to ask how to extract the month from a date?
i saved the date in yyyy/mm/dd format, and how do i need todo in order to know whether the date is in Jan, Feb or so on?

thanks.

Share this post


Link to post
Share on other sites
You can use a combination of the [a href=\"http://www.php.net/strtotime\" target=\"_blank\"]strtotime()[/a] and [a href=\"http://www.php.net/date\" target=\"_blank\"]date()[/a] functions:
[code]<?php
$date = '2006/06/01';
echo date('F',strtotime($date));
?>[/code]

Ken

Share this post


Link to post
Share on other sites
sorry, i have another question regarding to this. can i save the value of "echo date('F',strtotime($date));" into database? how am i suppose to tht??

thanks

Share this post


Link to post
Share on other sites
Instead of echoing the result, assign it to a variable and do whatever you want with it.
[code]<?php
$date = '2006/06/01';
$var = date('F',strtotime($date));
?>[/code]

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.