473,503 Members | 2,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting MySql timestamp to readable date/time in PHP/HTML content

all,

was able to piece together the following php/html code. Basically I
want to push an SQL query and format it, present it to an html
document. The problem appears with the SQL query.

When I execute the query from Mysql, it translates the date/time
perfectly along with the text msg - however when I call this from php
script below, it doesn't produce a date, just the msg text:

<snip>
// Performing SQL query
$query = "select date_format(time,'%b %D, %Y at %T
hrs'),
msg_text from journal order by time desc";
$result = mysql_query($query)
or die("Query failed : " . mysql_error());
// Printing results in HTML
echo "<table border=0>\n";
while ($line = mysql_fetch_array($result,
MYSQL_ASSOC)) {
printf("<tr><td><b>Date:</b> %s
<br><b>Journal:</b> %s<hr></td><tr>\n",
$line["time"],$line["msg_text"]);

<snip>

Does anyone know how I can reformat the date and time into the php
script instead of nothing?

Rgds,
Mike M...
Jul 17 '05 #1
2 6563
On 2004-01-02, mike m <mn***@optonline.net> wrote:
all,

was able to piece together the following php/html code. Basically I
want to push an SQL query and format it, present it to an html
document. The problem appears with the SQL query.

When I execute the query from Mysql, it translates the date/time
perfectly along with the text msg - however when I call this from php
script below, it doesn't produce a date, just the msg text:

<snip>
// Performing SQL query
$query = "select date_format(time,'%b %D, %Y at %T
hrs'),
msg_text from journal order by time desc";
$result = mysql_query($query)
or die("Query failed : " . mysql_error());
// Printing results in HTML
echo "<table border=0>\n";
while ($line = mysql_fetch_array($result,
MYSQL_ASSOC)) {
printf("<tr><td><b>Date:</b> %s
<br><b>Journal:</b> %s<hr></td><tr>\n",
$line["time"],$line["msg_text"]);

<snip>

Does anyone know how I can reformat the date and time into the php
script instead of nothing?

select date_format(.....) as alias

will put it in $line['alias']


--
verum ipsum factum
Jul 17 '05 #2
Tim Van Wassenhove <eu**@pi.be> wrote in message news:<bt************@ID-188825.news.uni-berlin.de>...
On 2004-01-02, mike m <mn***@optonline.net> wrote:
all,

was able to piece together the following php/html code. Basically I
want to push an SQL query and format it, present it to an html
document. The problem appears with the SQL query.

When I execute the query from Mysql, it translates the date/time
perfectly along with the text msg - however when I call this from php
script below, it doesn't produce a date, just the msg text:

<snip>
// Performing SQL query
$query = "select date_format(time,'%b %D, %Y at %T
hrs'),
msg_text from journal order by time desc";
$result = mysql_query($query)
or die("Query failed : " . mysql_error());
// Printing results in HTML
echo "<table border=0>\n";
while ($line = mysql_fetch_array($result,
MYSQL_ASSOC)) {
printf("<tr><td><b>Date:</b> %s
<br><b>Journal:</b> %s<hr></td><tr>\n",
$line["time"],$line["msg_text"]);

<snip>

Does anyone know how I can reformat the date and time into the php
script instead of nothing?

select date_format(.....) as alias

will put it in $line['alias']


Hi Tim,

Thanks Tim this workes great!

Regards,
Michael M
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2859
by: @$operamail$.com | last post by:
I have been trying to use a MySQL database with PHP having a date/time field set to timestamp(14). It keeps being set to a string of all zeroes (00000000000000). This happens evn if I use a query...
7
22032
by: Joshua Beall | last post by:
Hi All, Any thoughts on the easiest way to translate a MySQL timestamp (which looks like 20040422090941) to the datetime format (which looks like 2004-04-22 09:09:41). This is just to make it...
2
4687
by: zaceti | last post by:
I'm new to MySQL and I am having a problem selecting the highest valued date/time for a particular day. Here is the table structure: ...
5
2282
by: Gord | last post by:
Many scripts and calendars call client side system time in order to make presentations. However, the client's time may be improperly set, if set at all, and/or the relevant time may be from...
2
7019
by: TofuTheGreat | last post by:
I'm using "Now.ToOADate" for a record timestamp in a small database app (it's what I want to do so don't try to disuade me ;-D). Anyway. I store the value of Now.ToOADate in a string field in...
3
7787
by: pali | last post by:
I have a char column that contains date/time information (YYYYMMDDTTTTTT) in the following format: 20071002160603 What is the most efficient way to show this information in a query result as...
1
1708
by: Thierry Lam | last post by:
I have a python time string which has the following value: 1225137896 The above corresponds to 2008/10/27 16:04:56 What can I use to convert 1225137896 to a more readable date, time format?
0
1729
by: Syed Khaleel Ahamed | last post by:
Dear Sir, I want to get the difference of date/time captured in mysql and present date/time in jsp. I am using the following code to get, but its getting difference only in hrs, i used...
1
2732
by: lgarciaac | last post by:
Hi everybody, I have a problem and now idea how can be solved. The MySQL timestamp is frozen. Each time I run a command that should return the current date and time, it doesn't. For instance, I...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.