View Full Version : Convert date format to string
Lacuna
July 13th, 2005, 11:06 AM
Hey,
I am saving a field in date format and need to occasionally have it presented in string format instead of numeric. I.e. 11 will appear as 'November'.
I can't find how to do this.
Anyone know?
~ Lacuna :love:
bwh2
July 13th, 2005, 11:27 AM
you can use the date (http://us2.php.net/manual/en/function.date.php) and strtotime (http://us2.php.net/manual/en/function.strtotime.php) functions.
// assuming $date is what you pull from your db
print date("F j, Y", strtotime($date);
Lacuna
July 13th, 2005, 11:53 AM
I guess I should have mentioned that I work with asp, but I will go try to convert that. Thanks for your help, I will let you know how it turns out.
~ Lacuna :love:
Lacuna
July 13th, 2005, 12:41 PM
k, well i just ended up doing it this way for now..
function convertDate(byVal intMonth)
select case intMonth
Case 1
convertDate = "January"
Case 2
convertDate = "February"
Case 3
convertDate = "March"
Case 4
convertDate = "April"
Case 5
convertDate = "May"
Case 6
convertDate = "June"
Case 7
convertDate = "July"
Case 8
convertDate = "August"
Case 9
convertDate = "September"
Case 10
convertDate = "October"
Case 11
convertDate = "November"
Case 12
convertDate = "December"
end select
end function
and then called it with
strMonth = convertDate(intMonth)
~ Lacuna :love:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.