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
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
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 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
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
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
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
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
Current date in php
Current
date in php How to show the current
date in the HTML page using
PHP Script
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
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
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
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
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
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