Author |
Message |
probador
New Member


Joined: Apr 20, 2006
Posts: 24
|
Posted:
Tue Sep 05, 2006 6:43 am |
|
Here's my problem:
The datetime that is recorded in nuke_stories is the American format e.g.: 2006-03-04 whereas I need it to be day-month-year.
I tried changing local time format to es_ES (for Spain) under main preferences but no change whatsoever.
The I found the line of code that adds the info to the table
Code:$result = $db->sql_query("insert into ".$prefix."_stories values (NULL, '$catid', '$aid', '$subject', now(), '$hometext', '$bodytext', '0', '0', '$topic', '$aid', '$notes', '$ihome', '$alanguage', '$acomm', '$haspoll', '$id', '0', '0', '$associated')");
|
This is found under: modules/news/admin --> function AdminStory()
this now() is executed in the server and it responds with the American type of formatting, i guess.
I have no clue on how to change this stupid detail that is driving me crazy.
I am using raven76 v2.02.00
Thanks for your help. |
|
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Tue Sep 05, 2006 7:09 am |
|
Well, you cannot change from now() to anything else. MySQL is expecting this to be in a standard format for the datetime field. However, es_ES should have worked, IF the server this is running on has this language pack installed. I would check with your host about that.
The date string is reformatted in function formatTimestamp within mainfile.php, and it expects that PHP is handling the language conversion.
Unfortunately, that is about the extent of my knowledge on this. |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
probador

|
Posted:
Tue Sep 05, 2006 7:56 am |
|
Thanks for your quick answer montego:
Another solution I could use is make the user insert the date manually. For that, I'd need another field under nuke_stories, lets name it "manualdate".
I'll let you know if I am succesful.
Thanks. |
|
|
|
 |
fkelly
Former Moderator in Good Standing

Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY
|
Posted:
Tue Sep 05, 2006 8:35 am |
|
Quote: | Another solution I could use is make the user insert the date manually |
Yikes! Don't do that. Then you'll need to write code to make sure they don't make errors in entering the date or enter html or Lord knows what else.
There are a lot of date reformatting functions in PHP. Please just take a look at the manual ... you want the data to be stored in standard format in the database and if it can be automatic and based on now() all the better. Then use the functions to reformat it however you wish upon presentation.
You really don't want to be writing date validation functions for the entries on a Form if you don't have to. |
|
|
|
 |
probador

|
Posted:
Tue Sep 05, 2006 8:39 am |
|
Ok fkelly ill try to follow your example, but I dont really know where to start
Should I concentrate on looking for a way to save the time correctly on the database or a way to reformat the time when displayed.
My idea about manually entering it is because:
a) Only admins will publish articles
b) this date I need is ONLY for display purposes only in the article, nothing else.
What do you suggest? |
|
|
|
 |
Susann
Moderator

Joined: Dec 19, 2004
Posts: 3191
Location: Germany:Moderator German NukeSentinel Support
|
Posted:
Tue Sep 05, 2006 9:21 am |
|
|
|
 |
probador

|
Posted:
Tue Sep 05, 2006 9:31 am |
|
Susann thanks, but:
changing that I still get in the table of the databese a format like this:
2006-09-05 17:22:34
any ideas?? |
|
|
|
 |
probador

|
Posted:
Tue Sep 05, 2006 9:33 am |
|
If I make a php file with this:
Code:<?php
setlocale(LC_TIME, "es_ES");
echo strftime("%d de %B, %Y");
?>
|
I get the time fomat I need.
Now, how should I imp,lement this functions into AdminStory
Thank you all ! |
|
|
|
 |
fkelly

|
Posted:
Tue Sep 05, 2006 9:46 am |
|
Short answer: Google "PHP Manual" and look at date functions and the examples.
Slightly longer: Only registered users can see links on this board! Get registered or login!
There is an optional timestamp parameter to the strftime function you used. You need to "translate" the date/time information that's stored in your database into a timestamp and then pass that to strftime ... I believe. The Manual shows you how to do the timestamp conversion too.
The examples in the manual are very helpful if you read them carefully.
I don't mean to be unhelpful by the way but if you are going to customize this stuff then you are going to need to read the manual(s) or get a good book on PHP or most likely, both. |
|
|
|
 |
probador

|
Posted:
Tue Sep 05, 2006 9:49 am |
|
Actually I am reading the manual and trying to succesfully use the strftime function.
Thanks anyway for your support, I'll let you know if I get sth out of this. |
|
|
|
 |
Susann

|
Posted:
Tue Sep 05, 2006 10:21 am |
|
Hm, I only need to change this in my language files whatever date I like and its changed immediately. Very simple.
For example: /languages/lang_german.php contains this date string:
Code:define("_DATESTRING","%A, %d.%B. @ %T %Z");
|
changed to:
Code:define("_DATESTRING","%d. %m. %Y @ %T %Z");
|
that is: 31. 01. 2006 @ 16:14:18 CET
Check the date format you like: http://www.plus2net.com/php_tutorial/php_date_format.php |
Last edited by Susann on Tue Sep 05, 2006 10:24 am; edited 1 time in total |
|
|
 |
probador

|
Posted:
Tue Sep 05, 2006 10:22 am |
|
well here's how I did this:
Added to postAdminStory:
Code: $new_date = strftime("%d-%m-%Y");
|
And added new_date as a text field on nuke_stories
Then adding $new_date when inserting in the databese
Code:$result = $db->sql_query("insert into ".$prefix."_stories values (NULL, '$catid', '$aid', '$subject', now(), '$hometext', '$bodytext', '0', '0', '$topic', '$aid', '$notes', '$ihome', '$alanguage', '$acomm', '$haspoll', '$id', '0', '0', '$associated', '$fecha')");
|
Then changing news moduile / theme to display $new_date.
Thank you all ! |
|
|
|
 |
|