topflight Posted April 24, 2010 Share Posted April 24, 2010 Hello I have some columns where the time format is incorrect lets say that the time is 17:30 will in the database it will show 1730 or another example lets say that the time was suppose to be 6:30 instead it is 630. I would go in and edit each one of them except their is 15,000 rows, so may someone please tell me on how I can fix this problem thanks. Quote Link to comment https://forums.phpfreaks.com/topic/199625-time-help-please/ Share on other sites More sharing options...
oni-kun Posted April 25, 2010 Share Posted April 25, 2010 Use a handy in-SQL and PHP function to convert the date into a timestamp. Storing it in that format is not a good idea. Quote Link to comment https://forums.phpfreaks.com/topic/199625-time-help-please/#findComment-1047801 Share on other sites More sharing options...
havenpets Posted April 25, 2010 Share Posted April 25, 2010 Yeah what oni-kun said... Timestamps are much more easier to use and much cleaner and easier to "return" in any format you please! Quote Link to comment https://forums.phpfreaks.com/topic/199625-time-help-please/#findComment-1047853 Share on other sites More sharing options...
topflight Posted April 26, 2010 Author Share Posted April 26, 2010 However all this data was in a CSV so it their a way to fix this problem with a php script or code? Quote Link to comment https://forums.phpfreaks.com/topic/199625-time-help-please/#findComment-1048707 Share on other sites More sharing options...
topflight Posted April 29, 2010 Author Share Posted April 29, 2010 May I please have an example on how to do this. I have over 13000 rows in the table with this problem. Quote Link to comment https://forums.phpfreaks.com/topic/199625-time-help-please/#findComment-1050545 Share on other sites More sharing options...
Ken2k7 Posted April 29, 2010 Share Posted April 29, 2010 I would personally run 2 UPDATE queries. The first one to add a '0' in front of all values where the time is between 1:00 and 9:59. Then create a timestamp column and use MySQL UPDATE with LEFT() and RIGHT() to get the value and enter it into the new timestamp column. Quote Link to comment https://forums.phpfreaks.com/topic/199625-time-help-please/#findComment-1050553 Share on other sites More sharing options...
topflight Posted April 29, 2010 Author Share Posted April 29, 2010 Ok may you please give me an example code please. Quote Link to comment https://forums.phpfreaks.com/topic/199625-time-help-please/#findComment-1050561 Share on other sites More sharing options...
Ken2k7 Posted April 29, 2010 Share Posted April 29, 2010 Well, you may need to change the type in your database if the column isn't of a string type. I'm not going to write any example code. They're just 2 simple UPDATE queries. It's really not hard. Try it out and if you have troubles, then I'll consider it. Look up the functions I mentioned. There are examples on the MySQL site if you don't know how to use them. Quote Link to comment https://forums.phpfreaks.com/topic/199625-time-help-please/#findComment-1050563 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.