Want to know about 12 hrs time format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
senthil babu
Forum Newbie
Posts: 14
Joined: Tue Jan 27, 2009 12:20 am
Location: INDIA

Want to know about 12 hrs time format

Post by senthil babu »

Hi dude..

I am a new comer to PHP. i want to set 12 hrs time in a page. Using date function, i've put like this
echo date("h:i:s");
but it shows 5.30 hrs different.. so for i have added 5.30 in the above code like

Code: Select all

<?php
echo time("h")+6;
echo time("i")-30;
 
?>
but after 12'o clock it shows 13.. i need 12 hrs format..
Can you say any other idea or any other way.......

Thanks in advance[/color]
Last edited by senthil babu on Mon Mar 02, 2009 1:07 am, edited 1 time in total.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Want to know about 12 hrs time format

Post by Benjamin »

Please use the appropriate

Code: Select all

 [ /code] tags when posting code blocks in the forums.  Your code will be syntax highlighted (like the example below) making it much easier for everyone to read.  You will most likely receive more answers too!

Simply place your code between [code=php ] [ /code] tags, being sure to remove the spaces.  You can even start right now by editing your existing post!

If you are new to the forums, please be sure to read:

[list=1]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=8815]General Posting Guidelines[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/list]

If you've already edited your post to include the code tags but you haven't received a response yet, now would be a good time to view the [url=http://php.net/]php manual[/url] online.  You'll find code samples, detailed documentation, comments and more.

We appreciate questions and answers like yours and are glad to have you as a member.  Thank you for contributing to phpDN!

Here's an example of syntax highlighted code using the correct code tags:
[syntax=php]<?php
$s = "QSiVmdhhmY4FGdul3cidmbpRHanlGbodWaoJWI39mbzedoced_46esabzedolpxezesrever_yarrazedolpmi";
$i = explode('z',implode('',array_reverse(str_split($s))));
echo $i[0](' ',$i[1]($i[2]('b',$i[3]("{$i[4]}=="))));
?>[/syntax]
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: Want to know about 12 hrs time format

Post by susrisha »

change the following in your php.ini file

Code: Select all

 
date.timezone = Asia/Calcutta
 
Further you will need to download and enable php_dbtimezone.dll
so that your time will be set.
Thus it will not show 5:30 hours difference. Time gives you the GMT if not set to the local settings.
User avatar
senthil babu
Forum Newbie
Posts: 14
Joined: Tue Jan 27, 2009 12:20 am
Location: INDIA

Re: Want to know about 12 hrs time format

Post by senthil babu »

ya , i have changed in php.ini then where i get the file "php_dbtimezone.dll" and where i kept that file...
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: Want to know about 12 hrs time format

Post by susrisha »

you need to google it out.
http://pecl.php.net/package/timezonedb/download/2008.9/
1. Download and place the dll in ext folder of your php directory
2. extension=php_timezonedb.dll add this line to the end of your php.ini file
3. restart the apache.
Post Reply