how to get a pc time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hemashiki
    New Member
    • Aug 2006
    • 34

    how to get a pc time

    hi all
    i want to get current pc(personal computer) time using php
    can anyone suggest me
  • Weisbartb
    New Member
    • Aug 2007
    • 36

    #2
    [PHP]
    <?php
    echo echo date('l dS \of F Y h:i:s A');
    ?>
    [/php]
    You can read more about the date function here

    Comment

    • hemashiki
      New Member
      • Aug 2006
      • 34

      #3
      thanks for ur quick reply

      here i used like this date('Y-m-d h:i:s A') as well as date('l dS \of F Y h:i:s A')
      but both doesn't shows the current pc time
      is there anyother way to get pc time??????????

      Comment

      • Weisbartb
        New Member
        • Aug 2007
        • 36

        #4
        Do you want the users current pc time? If so thats a javascript script question.

        Sorry! We can't seem to find the resource you're looking for

        That link should tell you how to use the date object thats built in.

        Comment

        • hemashiki
          New Member
          • Aug 2006
          • 34

          #5
          s,i want users pc time

          cant we get this feature in php?????????

          Comment

          • hemashiki
            New Member
            • Aug 2006
            • 34

            #6
            hi
            here i used like this
            $a='<script type="text/javascript"> document.write( Date()) </script>';
            echo "$a";
            now its working.
            but i want to store this variable into mysql database.
            In what data type????should i store in database???????

            Comment

            • Weisbartb
              New Member
              • Aug 2007
              • 36

              #7
              You would need to auto populate a forum with the date object then have it auto submit on page load. Please see the javascript form for additional help on this.

              Comment

              • gregerly
                Recognized Expert New Member
                • Sep 2006
                • 192

                #8
                Originally posted by hemashiki
                hi
                here i used like this
                $a='<script type="text/javascript"> document.write( Date()) </script>';
                echo "$a";
                now its working.
                but i want to store this variable into mysql database.
                In what data type????should i store in database???????
                Hi Hemashiki,

                You haven't given us much info to go on. You said you wanted to store the users current time in the database, then ask if you should. That all depends on what your application is supposed to do. Are you requirements that your database store the users current time? If so, then yes you should store it. MySQL has a few different date / time datatypes. Check This Out

                You could expand the above code by doing this:

                [PHP]$a='<script type="text/javascript"> document.write( Date()) </script>';
                $sql = "INSERT INTO myTable VALUES ('$a');";
                $result=mysql_q uery($sql);[/PHP]

                You wouldn't need to auto populate and form fields or auto submit anything, just handle it all on the server and you'll be good to go.

                If this doesn't answer your question, post more info on what your app is supposed to do, and we can probably help you out.

                Thanks,

                Greg

                Comment

                • pitchke
                  New Member
                  • Sep 2007
                  • 7

                  #9
                  hey hi....!try printing this ' ".date('y-m-d h:m:s')."' this should give you current system time



                  Cheers..
                  Tarun

                  Comment

                  • kovik
                    Recognized Expert Top Contributor
                    • Jun 2007
                    • 1044

                    #10
                    Originally posted by pitchke
                    hey hi....!try printing this ' ".date('y-m-d h:m:s')."' this should give you current system time
                    No it won't. We went over that already. This gives the server time, not the user's.


                    Anyway, there is really no reason to have the user's time. Hell, it's probably the wrong time anyway. :P
                    You should only need to use your server's time (and make sure your host keeps their server time correct).

                    Comment

                    • judhisahoo
                      New Member
                      • Nov 2011
                      • 1

                      #11
                      Hi hemashiki,

                      thanks...

                      $a='<script type="text/javascript"> document.write( Date()) </script>';

                      Greate..It work like a charm..

                      Comment

                      Working...