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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.