WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder



Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Local Time clock and Server time usign PHP and JavaScript
Categories : PHP, Java Script, Date Time, Beginner Guides Click here to Update Your Picture
Vijit Patil
Date : Apr 26th 2007
Grade : 3 of 5 (graded 9 times)
Viewed : 62942
File : 4621.zip
Images : Image 1
Search : More code by Vijit Patil
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

In this simple script you know your server time when your script is executed and also you get your current time stamp.

We use the PHP getdate() function which gives us an array containing the date information of the timestamp, or the current local time if no timestamp is given. We give time() as input to getdate() and get an array. That array is used to Calculate the server time. Also we calculate the local time with JavaScript.

more resources at : http://www.techgyan4u.com/
Please see code for details....

<br><br>
<span id="clock">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
    function getthedate(){
        var mydate=new Date();
        var hours=mydate.getHours();
        var minutes=mydate.getMinutes();
        var seconds=mydate.getSeconds();
        var dn="AM";
        if (hours>=12) dn="PM";
        if (hours>12) hours=hours-12;       
        if (hours==0) hours=12;
        if (minutes<=9) minutes="0"+minutes;
        if (seconds<=9)    seconds="0"+seconds;
       

        var cdate="<b>Local Time</b> "+hours+":"+minutes+":"+seconds+" "+dn+"<BR>";
        if (document.all)
            document.all.clock.innerHTML=cdate;
        else if (document.getElementById)
            document.getElementById("clock").innerHTML=cdate;
        else
            document.write(cdate);
    }
    if (!document.all&&!document.getElementById) getthedate();

    function goforit(){
        if (document.all||document.getElementById) setInterval("getthedate()",1000);
    }
    window.onload=goforit;
// End -->
</SCRIPT>
</span>
 
<b>Server Time</b>
<?php

        $thetimeis
= getdate(time());
           
$thehour = $thetimeis['hours'];
           
$theminute = $thetimeis['minutes'];
           
$thesecond = $thetimeis['seconds'];
        if(
$thehour > 12){
           
$thehour = $thehour - 12;
           
$dn = "PM";
        }else{
           
$dn = "AM";
        }
       
echo
"$thehour: $theminute:$thesecond $dn";
?>   
</p>



Simple Javascript CSS Digital Clock
Categories : Java Script, Date Time, CSS, Beginner Guides, Web Design
How to Insert a Date Format Into MySQL from PHP
Categories : PHP, Databases, MySQL, Date Time, Beginner Guides
Date Validation using JavaScript. Intended to use it as checkdate() from PHP.
Categories : Java Script, Date Time, PHP
Calendars to choose a range of dates , reservation events ...
Categories : PHP, Calendar, Java Script, Date Time
PHP and javascript mouseover, mouseout, and mousedown events
Categories : PHP, Java Script, Form Processing, Beginner Guides
PHP Calendar
Categories : PHP, Calendar, Date Time, Java Script, CSS
Change the background color of a website daily dynamically using the php date function to get the current day of the week and depending on that day, set the background color for the web page.
Categories : PHP, Date Time, Beginner Guides, Web Design
Script loading time
Categories : PHP, Beginner Guides, Date Time
Count Number Of weeks in Month
Categories : PHP, Date Time, Beginner Guides
Find the day of the week for any given year/month/day.
Categories : PHP, Date Time, Data Validation, Algorithms, Beginner Guides
enhanced date picker with jcript checking for a dynamic date input
Categories : PHP, Java Script, Date Time, Calendar, Arrays
Newbie Notes #9 - Hyperlinking a post
Categories : PHP, Java Script, HTML and PHP, Beginner Guides
Local-to-user date and time display regardless of time zone or where the website's server is located
Categories : PHP, Date Time, HTML and PHP, Java Script
Find if a year is leap.
Categories : PHP, Date Time, Beginner Guides, Data Validation
Easy alert box pop-up function
Categories : PHP, Java Script, Beginner Guides