doubledee Posted April 25, 2011 Share Posted April 25, 2011 In my Payment Form, I have an ExpMonth (e.g. '01') and ExpYear (e.g. '2011'). Each value is assigned to $expMonth and $expYear respectively. I then need to combine them and keep the format ('MMYYYY'). I am afraid that this code may truncate leading zeros... $expDate = $expMonth . $expYear Will my code work, or do I need to do something else to ensure the Month stays ('MM') and the year stays ('YYYY')? Debbie Link to comment https://forums.phpfreaks.com/topic/234621-keeping-dates-as-text/ Share on other sites More sharing options...
kenrbnsn Posted April 25, 2011 Share Posted April 25, 2011 Did you try it? It works fine. Ken Link to comment https://forums.phpfreaks.com/topic/234621-keeping-dates-as-text/#findComment-1205724 Share on other sites More sharing options...
doubledee Posted April 25, 2011 Author Share Posted April 25, 2011 Did you try it? It works fine. Ken With PHP's dynamic typing I thought it might strip off the leading zeros and convert the string values into integers... Debbie Link to comment https://forums.phpfreaks.com/topic/234621-keeping-dates-as-text/#findComment-1205727 Share on other sites More sharing options...
Fadion Posted April 25, 2011 Share Posted April 25, 2011 With PHP's dynamic typing I thought it might strip off the leading zeros and convert the string values into integers... Debbie It is called Week Typing (aka Loose Typing) actually. And no, truncation can't occur as you're concatenating strings and the result will obviously be a string. Link to comment https://forums.phpfreaks.com/topic/234621-keeping-dates-as-text/#findComment-1205730 Share on other sites More sharing options...
doubledee Posted April 25, 2011 Author Share Posted April 25, 2011 With PHP's dynamic typing I thought it might strip off the leading zeros and convert the string values into integers... Debbie It is called Week Typing (aka Loose Typing) actually. And no, truncation can't occur as you're concatenating strings and the result will obviously be a string. Okay, but my fear was that it would convert '02' to '2' and then concatenate... Anyways... Thanks, Debbie Link to comment https://forums.phpfreaks.com/topic/234621-keeping-dates-as-text/#findComment-1205731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.