EchoFool Posted September 26, 2011 Share Posted September 26, 2011 Hey, I need help with my date & time string. I need to edit it do show in a string + also use it for calculating things like when the date has passed. The string is like this: <?php $string = '2011-01-01 00:00 AM'; ?> So i wanted to check if there was a function that can automatically convert it, so it would say for example: Sunday, 1st of January 2011 00:00 AM But at the same time compare $string against server time to see if the date has expired? Hope you can help Quote Link to comment https://forums.phpfreaks.com/topic/247867-datetime-help/ Share on other sites More sharing options...
Pikachu2000 Posted September 26, 2011 Share Posted September 26, 2011 Is this time string coming from a database query, or elsewhere? Quote Link to comment https://forums.phpfreaks.com/topic/247867-datetime-help/#findComment-1272772 Share on other sites More sharing options...
EchoFool Posted September 26, 2011 Author Share Posted September 26, 2011 In the database the value is stored in that precise format shown above as it was created from a form that the user enters the data. Quote Link to comment https://forums.phpfreaks.com/topic/247867-datetime-help/#findComment-1272774 Share on other sites More sharing options...
codeprada Posted September 26, 2011 Share Posted September 26, 2011 Your date doesn't have seconds so using date_parse will result in a few errors. You could have used the array returned to build a timestamp with mktime then format your date with the date function. Quote Link to comment https://forums.phpfreaks.com/topic/247867-datetime-help/#findComment-1272776 Share on other sites More sharing options...
Pikachu2000 Posted September 26, 2011 Share Posted September 26, 2011 OK, so are you trying to change the format for display after retrieving from the database, or before inserting it? (It should really be stored in a DATETIME data type field in the DB, BTW.) Quote Link to comment https://forums.phpfreaks.com/topic/247867-datetime-help/#findComment-1272777 Share on other sites More sharing options...
EchoFool Posted September 26, 2011 Author Share Posted September 26, 2011 Well i don't know how to store it in date time formate because it asks for the second which i don't require. IT inserts in that format then i load it from a query and then i want to display it but also do some checks against in time format =/ Quote Link to comment https://forums.phpfreaks.com/topic/247867-datetime-help/#findComment-1272790 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.