Page 1 of 1

Date format

Posted: Wed Jul 15, 2009 4:43 pm
by Jogge
Script URL:Latest
Version of script:1.6
Hosting company:Binero
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:Forum

Write your message below:

I have test to make the date in another language but i can´t get it to work. Have also read a post about this dated mars and there are still no answer to that.

So i just ask here if there are someone that can help me on this.

It look like this now
Tillagd: July 15, 2009

But i whant it in swedish like this
Tillagd: 15 Juli, 2009 kl. 18.44

Think this is hardcoded but it must go and changes some way...or?

Thanks
Jogge

Posted: Wed Jul 15, 2009 9:55 pm
by Henrie
Hello Jogge.

I use this solution:
viewtopic.php?p=8447#8447

(and here the same solution, but described a little different, for version 1.35
viewtopic.php?p=3080#3080)

i think the setlocale string for swedish is setlocale(LC_TIME, "Swedish", "sv_SE"); i could not test te sv_SE part because i don't have a linux server with swedish locale installed. The Swedish part for windows servers works)

Or you can use this script (translate to swedish ofcourse):
viewtopic.php?p=10658#10658


Greetings,
Henrie

Posted: Thu Jul 16, 2009 6:03 am
by Jogge
Hello Henrie

Thanks for your solution it work great. I test the first solution and i have this.

torsdag 16 juli 2009, 08:01

that look great in swedish, but i have only one question more.

How can i changes the code so that i have a big T and J for the day and mounth.

Big thanks again

Jogge

Posted: Thu Jul 16, 2009 8:23 am
by Henrie
Hello Jogge,

For information about the possible codes for the strftime function, look at this page
http://www.php.net/manual/en/function.strftime.php

Unfortunately, i could not look if capitals are a part of it, because the site was unreachable just now.

Anyhow, I think the strings depend on the locale installed on the server.

Greetings,
Henrie

Date format

Posted: Thu Jul 16, 2009 9:39 am
by Jogge
Hi again Henrie.

I shall check the site but as you say it´s down.

I let you now when i have found the solution

Thanks again

Jogge

Date format

Posted: Thu Jul 16, 2009 6:22 pm
by Jogge
Hi again Henrie.

Think i stay with your first solution, can get it to work with big characters in day and mounth

Thanks

Jogge

Posted: Thu Jul 16, 2009 6:52 pm
by Henrie
I see the php.net site can be reached now again.
And indeed, no alternative code for starting capitals. So it must be defined in the locale strings on the server.
If done correctly the first letter of days and months should be as definied in the grammatical rules of the country.
So when you say it starts with lower case letter this is the normal rule in Sweden. Offcourse this doesn't take in account the starting capital of a sentence.

Greetings,
Henrie

Date format Dutch

Posted: Mon Dec 28, 2009 10:48 pm
by toontjew
Hi,

I use latest version 1.7, were kan I change the date format.
I want to see in my gbook date - month - year.

I tried the format as above but nothing changes.

Language I use is Dutch.

Greetings

Toontjew

Posted: Tue Dec 29, 2009 11:55 am
by Henrie
Hello Toontjew,,

In the gbook.php (version 1.7) file find the following code (starting at line 875)

Code: Select all

	$m = date('m');
	if (isset($lang['m'.$m]))
	{
		$added = $lang['m'.$m] . date(" j, Y");
	}
	else
	{
		$added = date("F j, Y");
	}
For displaying date like this: 29 december 2009, change it to

Code: Select all

	$m = date('m');
	if (isset($lang['m'.$m]))
	{
		$added = date(" j ") . $lang['m'.$m] . date(" Y");
	}
	else
	{
		$added = date("j-n-Y");
	}
For displaying only numbers date like: 29-12-2009, change it to

Code: Select all

	{
		$added = date("j-n-Y");
	}
Greetings,
Henrie

Posted: Sun Jan 24, 2010 10:53 am
by PiPPi
Hello,

First post, I really appreciate the work done with Gbook.

Seems like the solution above has changed just a tad since the introduction of a separate language file.

The way I got this to work in 1.7 was to follow the instructions above but also to delete the "if"-statements with start on row 876 (as per the row numbering in the defaualt gbook.php 1.7).

For 1.7
Remove rows 876 to 882

Code: Select all

	if (isset($lang['m'.$m]))
	{
		$added = $lang['m'.$m] . date(" j, Y");
	}
	else
	{
		$added = date("F j, Y");
and replace with

Code: Select all

	{
		setlocale(LC_TIME, "sv_SE");
		$added=strftime("%A %d %B %Y, %H:%M");
Modify "setlocale" and "strftime" to your own preferences.

Regards
PiPPi
Stockholm, Sweden

Posted: Sun Jan 24, 2010 12:01 pm
by Henrie
The changed function was done to be not dependent on the strftime function which is not supported by all servers. Your solution depends also on the strftime function.

To get the same result with only the php date function you can do the following.
Open your language file language.inc.php (or in my case nederlands.inc.php) and add the following (example is in english, change it to your own language).

Code: Select all

$lang['w0']='Sunday';
$lang['w1']='Monday';
$lang['w2']='Tuesday';
$lang['w3']='Wednesday';
$lang['w4']='Thursday';
$lang['w5']='Friday';
$lang['w6']='Saturday';
Than in the file gbook.php find line 878 (in version 1.7)

Code: Select all

		$added = $lang['m'.$m] . date(" j, Y");
and change it to something like

Code: Select all

$added =  $lang['w'.$w] . date(" j ") . $lang['m'.$m] . date(" Y") . " at " . date("G:i");
This will output: Sunday 24 january 2010 at 13:01

Than in the file gbook.php find line 875 (in version 1.7)

Code: Select all

$m = date('m');
and insert directly below it

Code: Select all

$w = date('w');
This is inserted before line 876 which has the code if (isset($lang['m'.$m])

Now you have nationalised date string with day and time without using the strftime function.
To read more about the date function, use this link: http://www.php.net/manual/en/function.date.php

Posted: Sun Jan 24, 2010 1:42 pm
by PiPPi
Many thanks,

Nice clean code and not dependent on the server setup.

Just one more to go, viewtopic.php?p=12708#12708 :lol:

Regards
PiPPi

Re: Date format

Posted: Sat Nov 12, 2011 4:33 pm
by pagallery
I've followed the instructions for adding the time to the date and it's worked fine, except that the time is 5 hours behind my actual time. How do I tell it to use UK time? (My server is in the USA)

I'd like to say thanks for making this script available - the guestbook is a lot better and has more functionality than a lot of the others I looked at.

Re: Date format

Posted: Sat Nov 12, 2011 4:53 pm
by Henrie
pagallery wrote:I've followed the instructions for adding the time to the date and it's worked fine, except that the time is 5 hours behind my actual time. How do I tell it to use UK time? (My server is in the USA)
Please take a look at the following topic viewtopic.php?f=3&t=2421

Greetings,
Henrie