doforumda Posted October 19, 2009 Share Posted October 19, 2009 i need help with date function <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body> <?php $db = mysql_connect("localhost"); mysql_select_db("test", $db); $query = "select * from date"; $result = mysql_query($query); while($record = mysql_fetch_assoc($result)) { echo $record['date']."<br><br>"; } ?> </body> </html> through above code i am trying to echo date from database. but the problem is it echoes in this format "year month day" but i want it in "day month year" format how can i do this? Link to comment https://forums.phpfreaks.com/topic/178175-date-function-help/ Share on other sites More sharing options...
jmr3460 Posted October 19, 2009 Share Posted October 19, 2009 What I have done in the past is explode('-', $records['date']). Then assign each array value to a variable and echo in the order I wanted. Although this destroys the date value in case you wanted to use it as date somewhere else. I think there is some functions like strtotime() or something like that, I think this converts string to unix timestamp which is in seconds from January 1, 1970. Link to comment https://forums.phpfreaks.com/topic/178175-date-function-help/#findComment-939466 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.