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