Hailwood Posted July 1, 2010 Share Posted July 1, 2010 hi there, how should i go about formatting a mysql datetime with php? i have tried Date('jS M Y', $qry['msg_add_date']) but i simply get 1st Jan 1970 Quote Link to comment https://forums.phpfreaks.com/topic/206381-format-mysql-datetime-with-php/ Share on other sites More sharing options...
trq Posted July 1, 2010 Share Posted July 1, 2010 Your much better off doing this within your query... DATE_FORMAT. Quote Link to comment https://forums.phpfreaks.com/topic/206381-format-mysql-datetime-with-php/#findComment-1079631 Share on other sites More sharing options...
Hailwood Posted July 1, 2010 Author Share Posted July 1, 2010 thorpe do you ever sleep? haha but yeah, i thought about doing that, except this table has over 300 columns (not designed nor can be changed by me) and so the query is is select * ... while($row = mysql_fetch-assoc...) { foreach($row as $k => $v ) $$k = $v; so i cant really do it in the query cheers. came across using strtotime on it before using date Quote Link to comment https://forums.phpfreaks.com/topic/206381-format-mysql-datetime-with-php/#findComment-1079639 Share on other sites More sharing options...
trq Posted July 1, 2010 Share Posted July 1, 2010 What format do the dates appear to be in? Example? Quote Link to comment https://forums.phpfreaks.com/topic/206381-format-mysql-datetime-with-php/#findComment-1079641 Share on other sites More sharing options...
Hailwood Posted July 1, 2010 Author Share Posted July 1, 2010 just normal date time i.e 2010-07-01 22:42:21 Quote Link to comment https://forums.phpfreaks.com/topic/206381-format-mysql-datetime-with-php/#findComment-1079643 Share on other sites More sharing options...
trq Posted July 1, 2010 Share Posted July 1, 2010 date takes a timestamp, not a formatted date. You'll want to run your dates through strtotime to get a timestamp then into date. Quote Link to comment https://forums.phpfreaks.com/topic/206381-format-mysql-datetime-with-php/#findComment-1079647 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.