web_master Posted April 14, 2008 Share Posted April 14, 2008 hi, I got in dBase numbers of months in cells with INT, this result numbers of month like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 In rows there is a lots of different month-numbers like: id | name | month | day | ------------------------------- 1 | Willie | 1 | 6 | ------------------------------- 2 | Johny | 6 | 7 | ------------------------------- 3 | Zelda | 7 | 12 | ------------------------------- etc. so, how can I chage all the numbers to begin with 0 (zero) like: id | name | month | day | ------------------------------- 1 | Willie | 01 | 06 | ------------------------------- 2 | Johny | 06 | 07 | ------------------------------- 3 | Zelda | 07 | 12 | ------------------------------- thnx Link to comment https://forums.phpfreaks.com/topic/101083-solved-change-123-to-010203-in-dbase/ Share on other sites More sharing options...
discomatt Posted April 14, 2008 Share Posted April 14, 2008 unsigned_zerofill Link to comment https://forums.phpfreaks.com/topic/101083-solved-change-123-to-010203-in-dbase/#findComment-516917 Share on other sites More sharing options...
soycharliente Posted April 14, 2008 Share Posted April 14, 2008 Use the date() function to format it when pulling it out. Link to comment https://forums.phpfreaks.com/topic/101083-solved-change-123-to-010203-in-dbase/#findComment-516918 Share on other sites More sharing options...
craygo Posted April 14, 2008 Share Posted April 14, 2008 <?php $m = $row['month']; $d = $row['day']; $month = strlen($m) < 2 ? "0".$m : $m; $day = strlen($d) < 2 ? "0".$d : $d; ?> Ray Link to comment https://forums.phpfreaks.com/topic/101083-solved-change-123-to-010203-in-dbase/#findComment-516929 Share on other sites More sharing options...
web_master Posted April 14, 2008 Author Share Posted April 14, 2008 Ill take the craygo's solution and its work great. Thanks all of You! (The SOLVED button still dont work here?) Link to comment https://forums.phpfreaks.com/topic/101083-solved-change-123-to-010203-in-dbase/#findComment-516943 Share on other sites More sharing options...
web_master Posted April 14, 2008 Author Share Posted April 14, 2008 I found SOLVED button in meantime Link to comment https://forums.phpfreaks.com/topic/101083-solved-change-123-to-010203-in-dbase/#findComment-516945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.