Jump to content

Recommended Posts

Posted

Hello everyone! :)

I have a problem with date and time of my new Guestbook script.

 

Here is my Guestbook: http://shinydust.net/guestbook

The problem is Mysql timezone, which results in function "datetime" in MySql Guestbook database, and appears near every entry.

I suppose the reason is that your server (mine is Server92) are located in USA, while I'm italian: so default timezone is wrong for Italy.

 

For example: as you can read, in last "Sciapy" entry date and time displays now 13/07/2005 23:53.

That's because I've changed the time manually in the database. ^_^''

First, when she posted in my Guestbook, default date and time was: 13/07/2005 17:53

 

I'm sure it's your timezone server.

But in my Guestbook I'd like to display GMT date and time for Europe, particularly italian date and time.

How can I do this?

Is there a way to change timezone in Cpanel or MySql database?

I've searched for an option, but didn't find nothing. :(

Otherwise, is there a special timezone table to add in the database, or a special code to display in my pages which modifies default timezone with the italian one?

 

Please, help me. ^_^

Many thanks in advance, bye bye! :D

:tchrocks:

Posted

Hi,

 

The server time is in the time zone which is correct for the server. If your time zone is different, then you need to modify the code to allow for that.

 

Most php code allows you to set a time zone in the admin / config (in the same way as you can set your time zone on this server, so it's correct for you).

 

I don't think the guestbook you are using allows for that, so you will need to look in the source code where it gets the time (template-tags.php), and modify the line to take account of the different time zone for you. For guestbook I think you will need to add "3600*X" where X is the numbers of hours shifted in time zone (6 in your case).

 

Alternatively you may be able to use the "putenv" function to set the time zone in php for that sccript.

Posted

Thanks for your fast and nice reply! :tchrocks:

I'll try to modify the PHP code, as you suggested me.

Hope to manage it! ^_^''

I'll let you know if there are other problems.

Bye, have a nice day! :*

 

Minhea

Posted (edited)

Uhm... I think I'm really confused. ^_^

This is more complicated then I expected. :)

In template-tags.php I've found this datetime string:

 

function entry_time($format='F jS, Y g:i A') {

global $entry;

echo date($format, strtotime($entry['date']));

 

Is this what is needed to me, the right place to add the timezone difference?

And where do I have to add that "+6*3600" string?

I've tried to add it after function $format, then tried to post.

But nothing changed at all. o_O'

Someone help me, please... I'm only a PHP novice. :D

Thank you!

 

EDIT:

I've modified the string in this way:

function entry_time($format='F jS, Y g:i A') {

global $entry;

echo date($format, strtotime($entry['date']))+3600*6;

Something strange happened: now all my dates appeared something like this 21607

Creepy. :tchrocks:

Sigh! :(

Edited by Minhea
Posted

Try

 

function entry_time($format='F jS, Y g:i A Z21600') {

global $entry;

echo date($format, strtotime($entry['date']));

 

 

Z is offset for time zone

21600 is 3600x6

Zvalue to make the time zone more

Z-value to make the time zone less

 

I think that will work.

Posted

Minhea, you almost had it! :flex: The time offset you're trying to add needs to be inside the outermost parenthesis:

>echo date($format, strtotime($entry['date'])+3600*6);

Posted

*__*

Thank you so much, both of you, for replying me! :yes:

I think I should have understand... I' ll try your script later, then I'll told you if it works in my GB.

Thanks again! :)

Posted

WEEEH... David, you were right: I've modified the string as you told me, and now the date is the italian one!!! :)

I'm happy! :D

Thank you so much! :yes:

 

Bye everyone, have a nice week-end! ^_^

  • 1 month later...
Posted

Hi!

 

I have a problem similar to Minhea. I live in Sweden and i'm reconfiguring a guestbook. I use MySQL and PHP.

 

This is the code:

 

>Written by <strong><?php entry_smart_name(); ?></strong> on <?php entry_time('F jS, Y'); ?> at <?php entry_time('g:i A'); ?>

 

And this is what it print out:

 

>Written by Tiffany on August 17th, 2005 at 2:35 PM

 

Sure, that's exactly what it should print out. But since i live in sweden that date-syntax is wrong.

 

I want it to print out lite this:

 

>Skrivet av Tiffany den 7e Augusti, 2005 klockan 14:35 PM

 

I need all the help i can get, my PHP and MySQL skills aren't very good. Thanks in advance

 

/Henrik

Posted

Welcome to the forum, Henrik.

 

Nice to see another Swede in the forum. :)

 

Unfortunately I don´t know the answer to this but hang in there and someone will know the answer.

Posted

Welcome to the forum :)

 

Instead of the line;

>Written by <strong><?php entry_smart_name(); ?></strong> on <?php entry_time('F jS, Y'); ?> at <?php entry_time('g:i A'); ?>

 

try

>Skrivet av <strong><?php entry_smart_name(); ?></strong> den <?php entry_time('F jS, Y Z21600'); ?> klockan <?php entry_time('g:i A Z21600'); ?>

 

The alternative route, I think, is to use

><?php setlocale('LC_TIME','swedish'); ?>

before this line.

 

Do you also want the month to be in Swedish?

Posted

Thank you guys!

 

Welcome to the forum :)

 

Instead of the line;

>Written by <strong><?php entry_smart_name(); ?></strong> on <?php entry_time('F jS, Y'); ?> at <?php entry_time('g:i A'); ?>

 

try

>Skrivet av <strong><?php entry_smart_name(); ?></strong> den <?php entry_time('F jS, Y Z21600'); ?> klockan <?php entry_time('g:i A Z21600'); ?>

 

The alternative route, I think, is to use

><?php setlocale('LC_TIME','swedish'); ?>

before this line.

 

Do you also want the month to be in Swedish?

 

When i tried:

 

>Skrivet av <strong><?php entry_smart_name(); ?></strong> den <?php entry_time('F jS, Y Z21600'); ?> klockan <?php entry_time('g:i A Z21600'); ?>

 

It gave me:

 

Skrivet av Tiffany den August 17th, 2005 720021600 klockan 12:35 PM 720021600

 

So that didn't work at all

 

I also tried:

 

>Skrivet av <strong><?php entry_smart_name(); ?></strong> den <?php setlocale('LC_TIME','swedish'); ?><?php entry_time('F jS, Y'); ?> klockan <?php entry_time('g:i A'); ?>

 

But it didn't make any difference att all from how it were before. This is how the whole file looks like;

 

><div class="entry" id="<?php entry_id(); ?>">

<p class="entrymetadata">
Skrivet av <strong><?php entry_smart_name(); ?></strong> den <?php entry_time('F jS, Y'); ?> klockan <?php entry_time('g:i A'); ?>
</p>

<?php entry_comment(); ?>

</div>

 

Any ideas? :)

Posted

Welcome to the forums, Henrik! :)

 

Using setlocale('LC_TIME','swedish'); localizes output only of the strftime() function, not the date() function.

 

In order to localize your dates, you'd need to alter the entry_time() function to something like this:

>function entry_time($format='%B %e, %Y %H:%M') {
global $entry;
setlocale(LC_TIME,'swedish');
echo strftime($format, strtotime($entry['date'])+3600*6);
}

Then you could use code like the following:

>Skrivet av <strong><?php entry_smart_name(); ?></strong> den <?php entry_time('%e %B, %Y'); ?> klockan <?php entry_time('%H:%M'); ?>

...which should produce the following output:

Skrivet av Tiffany den 17 augusti, 2005 klockan 20:35

That's about as close as I could make it to what you want without a significant amount of programming.

 

Hope this helps...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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