Display PHP clock with user input date and time

Ads
 

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

Ads









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  ... the formatted date string Example 1: <?php ECHO "<b>Date using
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
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
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
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
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
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
PHP tag that include the input date '3-Jan-2008' and further convert the input... Mysql Date Input       Mysql Date Input is used to give the input date and convert the input
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. Thanks
convert date time to int
convert date time to int  convert date time to int
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
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
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 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
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
Current date in php
Current date in php  How to show the current date in the HTML page using PHP Script
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
Mysql Date Arithmetic
Date Arithmetic is used to display the current date, interval in current date and time. Understand with Example The Tutorial illustrate... the select now ( ) query that return you the current date and time. SYNTAX:-date
php inserting date into mysql
php inserting date into mysql  php inserting date into mysql   Here is a php code that inserts date into mysql database. In the given code, data is a database table. <?php table $query_manual = "INSERT INTO data
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
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
display data in php
display data in php  i want data validation in javascript for my form data and it will display in php. my fields are name,emailid,address,country combobox,state combo box, i want only php page,can u wxplain process how it come
user defined date class
user defined date class  Develop a user defined date class with public.Fill the members using existing class method.implement the methods for finding current date(),days between method,advanced days and after days
user defined date class
user defined date class  Develop a user defined date class with public.Fill the members using existing class method.implement the methods for finding current date(),days between method,advanced days and after days
date and time in awt(java)
date and time in awt(java)  sir, do you have an example of date in awt java which can be view over a textfield.   Display time in JTextField import java.util.*; import javax.swing.*; import java.awt.event.*; public

Ads