Jump to content

[SOLVED] help with time()


spires

Recommended Posts

Hi,

 

Just a quick question.

 

I'm storing the time of use input into my database useing the time() function.

when i pull the info out of the database, how do i get it display the time?

 

At the moment i get - 1172262700

I want it to say something like - 20:30

 

How do i go about doing this?

 

Thanks for all of your help.

 

Link to comment
https://forums.phpfreaks.com/topic/39829-solved-help-with-time/
Share on other sites

I think what you want is the date() function. It can show you all sorts of time related information. You have to write something like echo date("d"); or something like that. Different letters in the time function display different information. Go to http://us2.php.net/manual/en/function.date.php for a list of all the things the date function can display.

 

Michael

Link to comment
https://forums.phpfreaks.com/topic/39829-solved-help-with-time/#findComment-192408
Share on other sites

I normally use the date function.

However, this only display the date in the wrong order,

I have been told that with the time function i can display

it in the right order.

 

Example:

DATE()

I want - 12.5.2007

I get - 2007.5.12

 

If you know a way of reversing this, that would really help me out.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/39829-solved-help-with-time/#findComment-192418
Share on other sites

<?php
 $fetch=mysql_fetch_assoc(mysql_query("SELECT mydate FROM mytable"));
  $mydate=$fetch['mydate'];
 echo 'Date from the database: '.$mydate.'<br />';
 echo 'Newly formatted: '.date("d.m.Y",$mydate)
?>

Hope that helps - I think I've got the date the write way round. As mentioned above, read up on date() for a complete list on how to format it how you want it.

 

EDIT: Fixed a typo and swapped the date format around to how you wanted it.

Link to comment
https://forums.phpfreaks.com/topic/39829-solved-help-with-time/#findComment-192432
Share on other sites

Hi Guys,

 

I'm slowly getting there.

 

'Yesideez'

I've tryed out your way and i get this:

 

Date from the database: 2007-02-23

Newly formatted: 01.01.1970

 

I have had 01.01.1970 come up lots of times before when trying things out.

 

Any more suggestions?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/39829-solved-help-with-time/#findComment-192524
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.