|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Date() not displaying all information
I have my site displaying times when news articles were edited last (if they were edited). I want it to show the date and time when it was edited However it is only showing the date and for time it is only showing 00:00. Here is the code:
PHP Code:
__________________
CHornJr "One day I'll know what I am doing" ![]() My Blog Suanhacky Lodge #49 Rebel Squadrons |
|
#2
|
||||
|
||||
|
My guess is either that your editing_date field is a date rather than a datetime field or that you're inserting dates with no time values into it if it's a datetime field. Select just the editing_date with no formatting and see what you get.
|
|
#3
|
||||
|
||||
|
My editing_date field is a timestamp field
|
|
#4
|
||||
|
||||
|
This has bitten me in the bum a number of times. You need to give your field an alias:
PHP Code:
Wrapping a function around it effectively changes the column name for the purposes of the output. |
|
#5
|
||||
|
||||
|
That did not seem to fix the problem completely because it is now showing 13:00 instead of the correct time.
I have attached the actual file just incase Last edited by CHornJr : October 4th, 2003 at 05:52 PM. |
|
#6
|
||||
|
||||
|
In the following code (starting at line 39):
PHP Code:
you're invoking $article, which is the variable you're putting $news['article_text'] into, when it seems you should be invoking $news. Also, in your query, you'll need to give an alias to the posting_date field as well. |
|
#7
|
||||
|
||||
|
Thank you for pointing out the call to the wrong variable. However, it is now showing the posting date as 12/31/1969 and the editing date & time as 12/31/1969 18:59.
I have attached the updated file |
|
#8
|
|||
|
|||
|
if your date field is datetime then you can try this sorry i just skipped through the post but this works
PHP Code:
the first one gets the date aspect of it formated in date time wed jan etch and the second gets the time as in 12:00:23 am etc.... put the code in your query and the date_field is your field that contains the date =] |
|
#9
|
||||
|
||||
|
It is a timestamp, not a datetime field
|
|
#11
|
||||
|
||||
|
I figured out the problem. I had it using the strtotime() function as well. That is what was screwing it up
PHP Code:
Thank you for all your help guys |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Date() not displaying all information |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|