:: Home Page      
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   Errors
   Refer this Site  Refer This Site to Your Friends  Site Map  Contact Us      
Categories >> Code Snippets >> Scripts_Markup Code >> PHP Code


1)how i get the current system time using php?
 Question Submitted By :: PHP Code
  I also faced this Question!!      
Answer Posted By  
 Answers were Sorted based on User's Feedback
# 1
$time_offset ="525"; // Change this to your time zone
$time_a = ($time_offset * 120);
$time = date("h:i:s",time() + $time_a);
echo 'Current time is : '.$time;

Is This Answer Correct ?    226 Yes 50 No
ishtiaq alam
# 2
print "<br>".date('h:i:s',$time_now);

Is This Answer Correct ?    162 Yes 44 No
# 3
U can done it by using current timestamp option. 

Is This Answer Correct ?    171 Yes 74 No
# 4
print date('h:i:s',$time_now);

Is This Answer Correct ?    79 Yes 21 No
monalisha mohanty
# 5
$time_offset ="525"; // Change this to your time zone
$time_a = ($time_offset * 120);
$time = date("h:i:s",time() + $time_a);
echo 'Current time is : '.$time;

Is This Answer Correct ?    78 Yes 28 No
# 6
To get the local time, you have add your time zone offset.
So the function is correct.

$time_offset ="5.5"; // Asia/Kolkatta Change this to your
time zone
$time_a = ($time_offset * 120);
$time = date("h:i:s",time() + $time_offset);
echo 'Current time is : '.$time;

One another method is setting the time zone in php.ini file
or setting it in your script page using this command.

date_default_timezone_set ("Asia/Calcutta"); 

Is This Answer Correct ?    27 Yes 7 No
prince joesph
# 7
echo date('h:i:s');

h: hours
i: minutes
s: seconds 

Is This Answer Correct ?    62 Yes 51 No
# 8
//first write this code on top of your file in which you
want //to display the date or time or both.


//only for indian users and for people form different parts
//just check this link and set the values within single

//now output date or time at any place in your file as shown

echo date("m/d/Y");
echo date("G.i:s");

Thank You 

Is This Answer Correct ?    14 Yes 8 No
# 9
use following line in your code :

date_default_timezone_set (“Asia/Calcutta”);

to set timestamp according to your area....

Here Calcutta is an Asian City name...Set it to yours one... 

Is This Answer Correct ?    8 Yes 2 No
# 10

Write this is to your php page and
write echo $time = date("H:i:s",time()); 

Is This Answer Correct ?    5 Yes 1 No

Other PHP Code Interview Questions
  Question Asked @ Answers
How many frameworks are in php?   1
What is meant by 404 errors in php? niit 2
How can import database to mysql using php code? wipro 1
How can get current system time continuously without refresh of page?   1
How to Connect and Insert Record to MYSQL using PHP?   6
What is used of phpinfo() function in php?   1
Hi I have a dynamic dropdown reading in data from a MQSql database, I need to refresh just the dropdown (not the whole page) for any new values in the database. I am trying to use the getElementById in javascript but I have no idea how to get it to refresh. Does any one have an examples or any ideas how this can be done? Regards Srilanka_3   4
If i have an array $string = array(1,2,6,2,9,6,7,3,1,2); How can i get only unique values from it? Array ( [0] => 1 [1] => 2 [2] => 6 [4] => 9 [6] => 7 [7] => 3 )   2
hi sir actually i use now day's ajax but i m having problem my opinion i thing this code is right becuse i make code for my side validation with ajax in php so but it is not run complete i m posting my code pls confirm and clear my some mistake and return send me with informatiom what was error so next time i will be care fully so i m sending u but replay so quick because tomorrow i have to present it some where,frist one is index.php and second is show.php show.php is database connectivity for testing   1
I have array like $array = array(1, "hello", 1, "world", "hello"); if i want the following output then how can i do this? Array ( [1] => 2 [hello] => 2 [world] => 1 ) niit 2
Which framework is best in php among Smarty, Cakephp, Joomla, Drupal, Zend or Something else...? If any then Why? hcl 2
What is difference between ksort and krsort in php?   1
For more PHP Code Interview Questions Click Here