Jump to content

date function help


doforumda

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.