Jump to content

Converting time from format in database


PNewCode
Go to solution Solved by Barand,

Recommended Posts

Hello. Can someone help me with what I need to add to the following line of code to make it echo as 
Jan 6 2023 11:59pm instead of 2023-01-06 21:59:22 

The column in the database is named "created_at" which is filled in when a user makes an account on my website.

The issue is that I cannot change the way the date enters the database when a user signs up for an account. So I have to translate it on the page to view this for this line. Here is the line of code I have.

<td><center><b><font color="green">'.$row["created_at"].'</font></b></td>

 

Link to comment
Share on other sites

@Barand I felt for sure you gave me the right answer, and you probably did. However I seem to have this wrong somehow. When I use the following, I echo blank spaces and gives the error
Warning: Undefined array key "created_at" in /home/vbauyvmy/public_html/peredy1/modshit/phtokens4.php on line 137
which is
 

<td><center><b><font color="green">'.$row["created_at"].'</font></b></td>


This is what I have in the query

 

$sql = "SELECT id,unique_id,fname,email,token,movie,movie2,date_format(created_at, '%b %e %Y %h:%i%p') FROM users ORDER BY fname";

 

(the second suggestion to put in that string gave me an undefined error on the whole page)
date('M j Y g:ia', strtotime($row['created_at']))

Edited by PNewCode
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.