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

thanks for the reply..but use tat in php....

<?php
$time_now=mktime(date('h')+5,date('i')+30,date('s'));
 print "<br>".date('h:i:s A',$time_now);
?>

Thats for php.

Cheers,
Naveen

09:42:53 AM...output

but my system timing is 3.00pm

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

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

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

<html>
<body>
<?php
$time_now=mktime(date('h')+5,date('i')+30,date('s'));
$time_now=date('h:i:s A',$time_now);
?>
Time: <input type="text" name="dat1" value="<?php echo $time_now; ?>">
</body>
</html>

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);

just use two line of codes...

$date = date_default_timezone_set('Asia/Kolkata');
$today = date("F j, Y, g:i a T");

in the php code and use $date where you want your values to reflect...That's it.

commented: correct +1

This code will benefit many people

Thnks @nav33n.
Its Help me a lot.

Use Time Zone

<?php

$date = date_default_timezone_set('Asia/Kolkata');

echo date("d/m/Y h:i:s a", time());

?>
Or Use Time Diferrence from GMT
<?php

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

echo date("d/m/Y h:i:s a", time());

?>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.