Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
probador
New Member
New Member



Joined: Apr 20, 2006
Posts: 24

PostPosted: Tue Sep 05, 2006 6:43 am Reply with quote

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.
 
View user's profile Send private message
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Tue Sep 05, 2006 7:09 am Reply with quote

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.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
probador







PostPosted: Tue Sep 05, 2006 7:56 am Reply with quote

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

PostPosted: Tue Sep 05, 2006 8:35 am Reply with quote

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.
 
View user's profile Send private message Visit poster's website
probador







PostPosted: Tue Sep 05, 2006 8:39 am Reply with quote

Ok fkelly ill try to follow your example, but I dont really know where to start Crying or Very sad

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

PostPosted: Tue Sep 05, 2006 9:21 am Reply with quote

You only need to change the datestring in the language files I believe:
[ Only registered users can see links on this board! Get registered or login! ]

Should work:

define("_DATESTRING","%d.%m.%Y")
 
View user's profile Send private message
probador







PostPosted: Tue Sep 05, 2006 9:31 am Reply with quote

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







PostPosted: Tue Sep 05, 2006 9:33 am Reply with quote

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







PostPosted: Tue Sep 05, 2006 9:46 am Reply with quote

Short answer: Google "PHP Manual" and look at date functions and the examples.

Slightly longer: http://www.php.net/manual/en/function.strftime.php

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







PostPosted: Tue Sep 05, 2006 9:49 am Reply with quote

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







PostPosted: Tue Sep 05, 2006 10:21 am Reply with quote

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: [ Only registered users can see links on this board! Get registered or login! ]


Last edited by Susann on Tue Sep 05, 2006 10:24 am; edited 1 time in total 
probador







PostPosted: Tue Sep 05, 2006 10:22 am Reply with quote

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 !
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©