I just wanted to know if there was some sort of built in function to adjust a mysql date from YYYY-MM-DD into either MM-DD-YYYY or better yet: DayofWeek, Month DD YYYY
Also, mysql ouputs time in a string like HH:MM:SS. How would I be able to take the HH, and see if it's greater than 12, to output as an am/pm? Can I convert the first 3 digits of a string into a numerical variable, or do I have to do a switch statement that offers 13-24 and default as cases?
I'm sure this is a pretty common thing to do, that's why I thought there might be some built-in functions.yeah, don't stroe it as mysql_date. store it as time() then you can manipulate it a lot better.Well, a few things.
#1: All the dates have to be stored in mysql, because they are time/date stamps of when orders are placed.
#2: The MySQL Date or time or datetime datatypes are nice, because simple > or < comparisons can put them in order by date.
#3: How is it easier as time()?Use date - <!-- w --><a class="postlink" href="http://www.php.net/datedon't">www.php.net/datedon't</a><!-- w --> use date, that is just as bad as mysql_date.
time puts it in a lot better, you can manipulate it very well. it keeps track of the total seconds from 1970 I believe. this way you have H:M:S right in one number. you can order it anyway you want this way.
you can still do what you want but you are making it hard on yourself.
you will have to make use of explode(), mktime() and date() together. if you were to keep this format HH:MM:SS
explode dthe number syou have there and then put them into mktime() that is in date()
$split = explode(":", $datevariable);
date("l dS of F Y h:i:s A" , mktime($split[0],$split[1],$split[2],0,0,0));
something to that effect.use the date_format in mysql
<!-- m --><a class="postlink" href="http://www.mysql.com/doc/en/Date_and_time_functions.htmlThanks">http://www.mysql.com/doc/en/Date_and_ti ... htmlThanks</a><!-- m --> illogique - that's perfect. I thought that there'd be something built-in...it's just built-into MySQL instead of into php.
Thanks
Also, mysql ouputs time in a string like HH:MM:SS. How would I be able to take the HH, and see if it's greater than 12, to output as an am/pm? Can I convert the first 3 digits of a string into a numerical variable, or do I have to do a switch statement that offers 13-24 and default as cases?
I'm sure this is a pretty common thing to do, that's why I thought there might be some built-in functions.yeah, don't stroe it as mysql_date. store it as time() then you can manipulate it a lot better.Well, a few things.
#1: All the dates have to be stored in mysql, because they are time/date stamps of when orders are placed.
#2: The MySQL Date or time or datetime datatypes are nice, because simple > or < comparisons can put them in order by date.
#3: How is it easier as time()?Use date - <!-- w --><a class="postlink" href="http://www.php.net/datedon't">www.php.net/datedon't</a><!-- w --> use date, that is just as bad as mysql_date.
time puts it in a lot better, you can manipulate it very well. it keeps track of the total seconds from 1970 I believe. this way you have H:M:S right in one number. you can order it anyway you want this way.
you can still do what you want but you are making it hard on yourself.
you will have to make use of explode(), mktime() and date() together. if you were to keep this format HH:MM:SS
explode dthe number syou have there and then put them into mktime() that is in date()
$split = explode(":", $datevariable);
date("l dS of F Y h:i:s A" , mktime($split[0],$split[1],$split[2],0,0,0));
something to that effect.use the date_format in mysql
<!-- m --><a class="postlink" href="http://www.mysql.com/doc/en/Date_and_time_functions.htmlThanks">http://www.mysql.com/doc/en/Date_and_ti ... htmlThanks</a><!-- m --> illogique - that's perfect. I thought that there'd be something built-in...it's just built-into MySQL instead of into php.
Thanks