User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,708 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,342 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1094 | Replies: 8 | Solved
Reply
Join Date: Nov 2007
Posts: 181
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

get indian time in php

  #1  
Dec 3rd, 2007
hi i am doing a attendance sheet appln...
i want to know how to get the current indian time,date,month and year.....
and i want to store that in mysql database

lydia
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: get indian time in php

  #2  
Dec 3rd, 2007
If you want current date and time to insert to a table, you can use now() function of mysql.

http://dev.mysql.com/doc/refman/5.1/...l#function_now
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Nov 2007
Posts: 181
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: get indian time in php

  #3  
Dec 4th, 2007
thanks for the reply..but use tat in php....
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: get indian time in php

  #4  
Dec 4th, 2007
  1. <?php
  2. $time_now=mktime(date('h')+5,date('i')+30,date('s'));
  3. print "<br>".date('h:i:s A',$time_now);
  4. ?>

Thats for php.

Cheers,
Naveen
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Nov 2007
Posts: 181
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: get indian time in php

  #5  
Dec 4th, 2007
09:42:53 AM...output

but my system timing is 3.00pm
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: get indian time in php

  #6  
Dec 4th, 2007
I am getting the right output. i am getting 03:14:16 PM which is the right time.

$time_now=mktime(date('h')+5,date('i')+30,date('s'));

date('h')+5 will add 5 hrs to UTC time.
date('i')+30 will add 30 mins to UTC time.

Since we are 5-30 hrs ahead of UTC time, i am sure this will work. It probably wont work if you have set some other timezone.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Nov 2007
Posts: 181
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: get indian time in php

  #7  
Dec 4th, 2007
can i know why u have given "<br>"...

Time<input type="text" name="dat1" value=<?php

$time_now=mktime(date('h')+5,date('i')+30,date('s'));

print .date('h:i:s A',$time_now);

?>>

because the about statement is not working
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: get indian time in php

  #8  
Dec 4th, 2007
<br> is to give a line break. That doesnt make any difference. Do you want indian time to be put in a text box ? Try this.
  1. <html>
  2. <body>
  3. <?php
  4. $time_now=mktime(date('h')+5,date('i')+30,date('s'));
  5. $time_now=date('h:i:s A',$time_now);
  6. ?>
  7. Time: <input type="text" name="dat1" value="<?php echo $time_now; ?>">
  8. </body>
  9. </html>
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jul 2008
Posts: 1
Reputation: sunilcsit is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sunilcsit sunilcsit is offline Offline
Newbie Poster

Re: get indian time in php

  #9  
Jul 1st, 2008
Hi this is sunil,
pls see this code,

$time_now=gmmktime(date('h')+5,date('i')+30,date('s'));

print "<br>".date('h:i:s A',$time_now);
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 2:56 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC