Display PHP clock with user input date and time

Display PHP clock with user input date and time

The following PHP code displays a clock with current date and time. I want the clock to receive user input date and time. How can this be done?

defaulttimezone_set("Asia/Kolkata"); if(@$_GET["action"]=="getTime"){ $time1 = Time();

 $date1 = date("m/d/Y h:i:s A",$time1);  
 //echo $date1; // time output for ajax request

 $aa=explode(" ",$date1);
 //echo "</br>";
 echo "Date: ".$aa[0];
 echo "</br>";
 echo "Time: " .$aa[1]; 
 die();  


}

?>

<div id="qwe"></div>

<script type="text/javascript">   
  window.onload = startInterval;  
  function startInterval() {  
    setInterval("startTime();",1000);  
  }
  function startTime() {
    AX = new ajaxObject("?action=getTime", showTime)
    AX.update(); // start Ajax Request   
  } 
  // CallBack 
  function showTime( data ){
    document.getElementById('qwe').innerHTML = data;
  }  
</script>  



<script type="text/javascript">
// Ajax Object - Constructor
function ajaxObject(url, callbackFunction) {
  var that=this;
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  };
  this.update =
  function(passData,postMethod) {
    if (that.updating) { return false; }
    that.AJAX = null;
    if (window.XMLHttpRequest) {
      that.AJAX=new XMLHttpRequest();
    }else{
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (that.AJAX==null) {
      return false;
    }else{
      that.AJAX.onreadystatechange = function() {
        if (that.AJAX.readyState==4) {
          that.updating=false;
          that.callback( that.AJAX.responseText, that.AJAX.status, that.AJAX.responseXML, that.AJAX.getAllResponseHeaders() );
          that.AJAX=null;
        }
      };
      //var dt= ; 
      that.updating = new Date();
      if (/post/i.test(postMethod)) {
        var uri=urlCall+(/\?/i.test(urlCall)?'&':'?')+'timestamp='+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.setRequestHeader("Content-Length", passData.length);
        that.AJAX.send(passData);
      }else{
        var uri=urlCall+(/\?/i.test(urlCall)?'&':'?')+passData+'Ã?tamp='+(that.updating.getTime());
        that.AJAX.open("GET", uri, true);
        that.AJAX.send(null);
      }
      return true;
    }
  };
  var urlCall = url;
  this.callback = callbackFunction || function (){};
}
</script>
View Answers

August 9, 2013 at 7:54 PM

to do so you have to write a small script because php date and time show the server time and date









Related Tutorials/Questions & Answers:
Display PHP clock with user input date and time
Display PHP clock with user input date and time  The following PHP code displays a clock with current date and time. I want the clock to receive user input date and time. How can this be done? <?php date<em>
PHP Display date and time
() function in PHP, it doesn't display the correct time and date for their region... PHP displaying the time and date into your timezone  ... Returns the formatted date string Example 1: <?php ECHO "<
Advertisements
php date input calendar
php date input calendar  I'm having an issue while writing the date input calendar function in PHP.. any help? Thanks
escaping user input in php
escaping user input in php  Is it possible to escape the user input while submitting data into database in PHP
How to convert date to time in PHP?
How to convert date to time in PHP?  Hi, programmer. The PHP..., but as a readable date and time, it leaves much to be desired. Luckily, the PHP... google search and found some PHP Date time scripts listed on the page. Glad
PHP Date and Time
PHP Date and Time The PHP Date and Time function is massively used... the functions of the software. ADS_TO_REPLACE_1 The PHP date and Time functions allow you to access the date and time from the server where your PHP scripts
Display Date and Time - Design concepts & design patterns
Display Date and Time  HI, Can u send me Html code displaying system date and time . Thanks Prakash  Hi Friend, Try the following code: System Date and Time var date = new Date(); document.write
PHP Date and Time Functions
The PHP Date and Time Functions functions allows the developer to read... to manipulate the date object in the PHP code. Here is the some of the examples of PHP Date and Time Functions.ADS_TO_REPLACE_1 Printing amount of seconds
PHP date function
PHP Date() Function PHP Date() function is used to display the date and time in a précised format.  With the help of PHP date function you can format... to display to format date and time in different style :ADS_TO_REPLACE_1 Syntax
PHP Date and Time
 The PHP Date and Time functions are very useful in manipulating the Date in your PHP program. The PHP Date and Time generates the current date and time... of PHP date function: Formatting Option
Display Current Date using JSP Custom(user define) Tag
Display Current Date using JSP Custom(user define) Tag In this section, we will discuss about how to display current date & time using  custom(user... In this Example, Current date & time will display using custom tag. Tag
Get Date and Time
current date and time in the user given format. To do all this we have first... Get Date and Time   ... whose time fields have been initialized with the current date and time. getTime
PHP Date and Time Date and time Tutorial
Date and time Learn how to use PHP Date and Time functions To get formatted date and time value you can use date() function. It is very easy to pass any format you want to get formatted time output. string date(string format, int
How to display the current time
. In this web portal i am going to display time. I am using <%= new java.util.Date() %> to display the time. But it display the time after that cannot changed...=CYAN> <TR><TD> <FORM NAME="clock_form"> <INPUT TYPE=TEXT
PHP Displaying the date and time in your timezone Tutorial
PHP Date Time Zone       In PHP Date Time Zone class displays the time of different time zone, along with time it is also capable of displaying the longitude, latitude and comment
Write an Applet which display current date and time on the web page??
Write an Applet which display current date and time on the web page??  Write an Applet which display current date and time on the web page??  Here is an applet code that display date and time. import java.applet.
Write an Applet which display current date and time on the web page??
Write an Applet which display current date and time on the web page??  Write an Applet which display current date and time on the web page?  Here is an applet code that display date and time. import java.applet.
PHP date_create
was introduced in PHP 5.1.0. Description DateTime date_create ([ string $time= "now" [, DateTimeZone $timezone= NULL ]] ) Parameters time... date_create () date_create function returns new DateTime object
Date & Time
Date & Time  How to insert System Date & Time in MS-ACCESS using Java
Date & Time
Date & Time  How to insert System Date & Time in MS-ACCESS using Java
Mysql Date Input
this example we use PHP tag that include the input date '3-Jan-2008' and further... Mysql Date Input       Mysql Date Input is used to give the input date and convert the input
PHP Date
PHP Date  Hi, How to use PHP Date functions in my PHP program? Thanks   Hi, PHP Date functions is very handy. It is used to progracess, format and create date objects in PHP. There are many ways to use PHP Date
The PHP Date() Function
The PHP Date() Function The PHP date() function is used for formatting the date and time. It formats a timestamp (a sequence of characters representing the date and/or time at which a certain event occurred) to make more readable
Time display - JSP-Servlet
Time display   In a web application or ina website if we display...' system time. Is there any difference between getting time using java Date class and JScript Date class in case of client or server side system time
Display Date - Java Beginners
Display Date  Plz send me sample java program that display day, date,year and crunent time. help me plz...  Hi friend, Code to display day,date,year and current time. import java.util.*; class DateExample
How to display mysql database records as per clock timing?
How to display mysql database records as per clock timing?  I want to display database records as per clock timing
php parse string to time
php parse string to time  I am looking for a solution to parse a string into a formatted date time string
php date format am pm
php date format am pm  how to set the date format that will display the date in both am pm format
php date function - Date Calendar
php date function  Hi, I am new to PHP. I am trying to get date from database. But, every time the date under 1970, it changes to 1970. Im...: 1960-12-02 (type is date ) In PHP : $dob= " 1960-12-02
Date comparison in PHP - PHP
Date comparison in PHP  I am looking for a date comparison code in PHP that can compare the date in between two different date formate.. for example: 11/12/1999 and 11/12/2001 to 11.11.1888 00:00:00 any idea on how
validate input php
validate input php  How to validate the input fields in PHP & HTML.   Hi, Please let's know many fields is to be validated. Then I will make an example for you.ADS_TO_REPLACE_1 Thanks
php date format change
php date format change  How to change the date format in PHP
convert date time to int
convert date time to int  convert date time to int
Java User Input
Java User Input  I am using Scanner class for user Input. Scanner s = new Scanner(System.in); String name = s.next(); but i am unable to store full name in name variable...how i can store full name plsss reply   use
Only Display Date
Only Display Date  I want to implement only date not time like that 20 Sep 2011. How can possiple it?   Your question is not clear. Which technology you use? java/.NET/SQl
javascript current date and time.
javascript current date and time.  How can we display current date and time using javascript?   <html> <head> <title>... with current day,date,time and GMT.You can have your own format
Add Date Time together
Add Date Time together  I want to add datetime with time and result must be datetime. i am unable to do please help me in php mysql but i need this in javascript. and first datetime is from the text box and another time is from
How to display date in JSP?
How to display date in JSP?  How to create a simple JSP program which displays date on the page? Thanks
php display errors
php display errors  i don't know how to display the error using PHP
user input to database
user input to database  /* * Studentinfo2App.java */ package studentinfo2; import java.sql.Connection; import java.sql.DriverManager; import... in my database user input from my applet does not show
user input to database
user input to database  /* * Studentinfo2App.java */ package studentinfo2; import java.sql.Connection; import java.sql.DriverManager; import... in my database user input from my applet does not show
user input to database
user input to database  /* * Studentinfo2App.java */ package studentinfo2; import java.sql.Connection; import java.sql.DriverManager; import... in my database user input from my applet does not show
button to accept user input
the radiobutton and spinner.The user input does not show on my Studentinfo.mdb...button to accept user input  private void jButton1ActionPerformed... that accepts firstname, lastname and gender from user and insert to database
calculation after if. user input
user input????   My apologies good evening peoples Once again I am...calculation after if. user input  System.out.print ("please select...[]args){ Scanner input=new Scanner(System.in); System.out.print
How Insert DateTime Vales into Mysql Databse from the front end application.But User Gives Date only from Datepicker,not Time
User Gives Date only from Datepicker,not Time  I am new developer in .net,I Have requirement..like this ,when user pick date from date picker not time only date he/she pick up,then click insert that time ,i want insert that date
How Insert DateTime Vales into Mysql Databse from the front end application.But User Gives Date only from Datepicker,not Time
User Gives Date only from Datepicker,not Time  I am new developer in .net,I Have requirement..like this ,when user pick date from date picker not time only date he/she pick up,then click insert that time ,i want insert that date
php date format validation
php date format validation  How to validate the date field in specific format in PHP
store input and display previous input as well current input. in jsp
store input and display previous input as well current input. in jsp  Hi Friend, In this JSP program i want display the previous input as well current inputs also. currently only current input i am able to display whenever i
date time picker
date time picker  I have enetered a date time picker in my jsp file. there is text field before the date time picker. What should i do so... the date time picker gets opened
How to read user input in C++
How to read user input in C++  How can i get an input from the users in C++?   You can use the standard input "cin" to get the input from user.. For example: int age; cin >> age

Ads