klinmy Posted April 13, 2006 Share Posted April 13, 2006 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. Link to comment https://forums.phpfreaks.com/topic/7323-extract-month-of-date/ Share on other sites More sharing options...
kenrbnsn Posted April 13, 2006 Share Posted April 13, 2006 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 Link to comment https://forums.phpfreaks.com/topic/7323-extract-month-of-date/#findComment-26646 Share on other sites More sharing options...
klinmy Posted April 13, 2006 Author Share Posted April 13, 2006 thanks alot Ken! Link to comment https://forums.phpfreaks.com/topic/7323-extract-month-of-date/#findComment-26648 Share on other sites More sharing options...
klinmy Posted April 13, 2006 Author Share Posted April 13, 2006 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 Link to comment https://forums.phpfreaks.com/topic/7323-extract-month-of-date/#findComment-26665 Share on other sites More sharing options...
kenrbnsn Posted April 13, 2006 Share Posted April 13, 2006 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 Link to comment https://forums.phpfreaks.com/topic/7323-extract-month-of-date/#findComment-26671 Share on other sites More sharing options...
klinmy Posted April 13, 2006 Author Share Posted April 13, 2006 it's done. :Dthanks really Link to comment https://forums.phpfreaks.com/topic/7323-extract-month-of-date/#findComment-26672 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.