Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8337029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:10:09+00:00 2026-06-09T04:10:09+00:00

I have the following two names in MySQL table: message is type text date

  • 0

I have the following two names in MySQL table:

message is type text

date is type datetime

<?php
while($row=mysql_fetch_array($result)){
?>
<tr>
     <td><div><a><? echo $row['message'] ?></a></div></td>
     <td><div><a><? echo $row['date']; ?></a></div></td>
</tr>
<?php
 }
?>

The output of the above table shows date in this format 2012-08-05 17:43:57

How to print date in this format 2012-08-05 (without time)?

I cannot change type datetime in MySQl (it’s required in different pages in different formats).

I’ve tried the following, but it doesn’t help (no printing at all)

<td><div><a><? echo $rows['date'](“Y-m-d”); ?></a></div></td>

p.s. other combinations of date format give me syntax error.

Any suggestion would be much appreciated,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:10:11+00:00Added an answer on June 9, 2026 at 4:10 am

    You want

    <?php echo date('Y-m-d', strtotime($row['date'])); ?>
    

    strtotime converts your datestring into a unix-timestamp

    then, the date function formats it properly according to the string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using mysql and php, I have two tables, I'm french so the table names
I have the following two tables in my mysql database. Table Name: groups id
I have a MySQL table with the following columns: id(int), date (timestamp), starttime(varchar), endtime(varchar),
I have following mysql table: Item Name Listing Fee Listing Type watch $0.20 LISTED
I have two mysql tables that have the following structure: Table 1: ---ID---------NAME------- ---1-----
I have the following two table: -Groups- Id Name -Members- Id GroupId (Group.Id is
I have one MySQL table, users , with the following columns: user_id (PK) email
I have the following prepared query I am using with mysql and php. It
I have a question about MySQL InnoDB. For example: I have the following table
I have the two following tables table A | id | name | |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.