close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Change time format

Thread began 10/26/2012 8:19 am by colinlangley441259 | Last modified 11/01/2012 1:37 pm by Jason Byrnes | 1757 views | 7 replies |

colinlangley441259

Change time format

Is there any way to change the time format from 00:00:00 to 00:00 please?

The code i have is:

<?php echo $row_Recordset1['from']; ?>

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

so the from column is storing the Time only? as hour:minutes:seconds? for example:

13:41:32

use the following which will convert the time to a full date, and use the date function to convert it to Hours:minutes


php:
<?php echo(date("H:i"strtotime("2012-1-1 ".$row_Recordset1['from']))); ?>
Sign in to reply to this post

SPT

Hi Jason,

I am trying to accomplish the same thing but different. :)

I wanted to show the month day, year and strip the time.

Original line is:
<?php echo($row_WADAblog['updated']); ?>

I have tried:
<?php echo(date("M d, Y", strtotime("00:00:00 ".$row_WADAblog['updated']))); ?>

But it displays Dec 31, 1969 for all.

I also tried the SQL DATE_FORMAT(updated "%M %d, %Y') AS updated
Maybe that was the wrong approach.

But get sql error.

Sign in to reply to this post

Jason ByrnesWebAssist

what is the original value of $row_WADAblog['updated']?

you can probably just us this code:

php:
<?php echo(date("M d, Y"strtotime($row_WADAblog['updated']))); ?>





the reason for adding a date to the code for the OP in this thread was that they had the time stored in the database as hh:ii:ss (ex. 12:41:22)and the wanted to strip the seconds(ex. 12:41). the strtotime command requires a full date (yyyy-mm-dd hh:ii:ss), so for the date command to work, a date needed to be added to the time (ex. "2012-1-1 ".$row_Recordset1['from']).


in your code, your adding time information to the date at the beginning which not the correct format.

Sign in to reply to this post

SPT

Original line is:
<?php echo($row_WADAblog['updated']); ?>

Your line worked great!! Thanks again!

Sign in to reply to this post

Jason ByrnesWebAssist

that wasn't the question.

the question was what the result of the original code was.

did you try using:

php:
<?php echo(date("M d, Y"strtotime($row_WADAblog['updated']))); ?>

as I suggested?

Sign in to reply to this post

SPT

did you try using:
PHP Code:
<?php echo(date("M d, Y", strtotime($row_WADAblog['updated']))); ?>
as I suggested?

Yes sir - and your code worked great. Just what I needed. Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

OK, glad to hear it is working.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...