Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with time values

Status
Not open for further replies.

hos2

Programmer
Joined
May 6, 2002
Messages
418
Location
NL
I have a mysql database where I have a time field. when the timefield is displayed like

$orlstarttime=$row["orlstarttime"];
print&quot;<td>$orlstarttime<br></td>&quot;;

I also see the seconds. and I just need the hour and minutes. when I try something like
strftime('%H:%M',$row[&quot;orlstarttime&quot;]);
the values are all the same 19:00 ??

how can I format a time value the way I want it ??
 
Part of the problem is that you're handing strftime() a string in the second parameter when it calls for an integer. You might try:
strftime('%H:%M',strtotime($row&quot;orlstarttime&quot;));

You could do the above or use a regular expression to get only the parts you want.

You could format it in your select query using the MySQL builtin function time_format():




Want the best answers? Ask the best questions: TANSTAAFL!!
 
ah this works, I also tried formatting it in mysql already. but for some strange reason everything got screwed up. so I went to the php time functions for the solution

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top