jwk811 Posted January 5, 2007 Share Posted January 5, 2007 how can i change a four digit number like the year 2006 into a two digit number with the last two digits remaining like 06? Link to comment https://forums.phpfreaks.com/topic/32920-change-the-number-2006-into-06/ Share on other sites More sharing options...
fert Posted January 5, 2007 Share Posted January 5, 2007 [code]$last=$year{2}.$year{3};[/code] Link to comment https://forums.phpfreaks.com/topic/32920-change-the-number-2006-into-06/#findComment-153258 Share on other sites More sharing options...
kenrbnsn Posted January 5, 2007 Share Posted January 5, 2007 Is there more to this question than meets the eye?Ken Link to comment https://forums.phpfreaks.com/topic/32920-change-the-number-2006-into-06/#findComment-153262 Share on other sites More sharing options...
jwk811 Posted January 5, 2007 Author Share Posted January 5, 2007 how about getting the last two digits in a sentence.. because i just relized that i store the date like this: January 14, 2006. How could I make it so it gets just the last two without knowing how many are in the string? Would I have to do a string count and subtract the difference? if thats the way to do it could you help me with that? im not too sure on how to do that either.. thanks! Link to comment https://forums.phpfreaks.com/topic/32920-change-the-number-2006-into-06/#findComment-153263 Share on other sites More sharing options...
kenrbnsn Posted January 5, 2007 Share Posted January 5, 2007 If you are storing the date in a database, you really should be storing it as a "date" type field. Tell us what you're using to format the date now.If you store it as a "date" field, you can always display it however you want.Ken Link to comment https://forums.phpfreaks.com/topic/32920-change-the-number-2006-into-06/#findComment-153266 Share on other sites More sharing options...
jwk811 Posted January 5, 2007 Author Share Posted January 5, 2007 nevermind forget about that part i got it.. i process it before it enters the data base and its separated then.. so i got that thanks.. that seems like a better idea to use a date row instead.. how could i put it into the db when in parts like there will be a select form for the month day and month how can you combine it to fit into the db in the date row? and how could i take it out so its set up like January 14, 2006? thanks for you help! Link to comment https://forums.phpfreaks.com/topic/32920-change-the-number-2006-into-06/#findComment-153268 Share on other sites More sharing options...
kenrbnsn Posted January 5, 2007 Share Posted January 5, 2007 Look at the [url=http://www.php.net/strtotime]strtotime()[/url] and [url=http://www.php.net/date]date()[/url] functions.Ken Link to comment https://forums.phpfreaks.com/topic/32920-change-the-number-2006-into-06/#findComment-153272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.