Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old November 12th, 2004, 11:28 AM
pdparry pdparry is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 pdparry User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to pdparry
Getting the Date from a client's machine

Hi,

I'd like to be able to tell *when* a form has been posted, ie. the *local* time from the client's machine and not the time it was received by the server.

I can extract the date from a client by doing this:
php Code:
Original - php Code
  1.  
  2. <script language="JavaScript">
  3. var now = new Date();
  4. </script>


Then I'd like to send the date along with the other data in the form. I've tried something like this but it isn't working.

php Code:
Original - php Code
  1. <form method="GET" action="process_form_date.php">
  2. <input name="localDate" type="hidden"
  3. <input type="submit" value="Get Date" onClick="javascript:getDate()">
  4. </form>


Any ideas?

Thanks,

PDP


Reply With Quote
  #2  
Old November 12th, 2004, 01:10 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Getting the Date from a client's machine

Talk about RTFMAATQY...

php Code:
Original - php Code
  1.  
  2. <html>
  3. <head>
  4. <title>Get date from local machine</title>
  5. <script type="text/javascript">
  6. function setDate()
  7. {   var now = new Date();
  8.     document.date.localDate.value = now;
  9.     }
  10. </script>
  11. </head>
  12. <body>
  13. <p>Click Submit to find when you submitted this form
  14. <form name="date" action="process_form_date.php">
  15. <input type="hidden" name="localDate" value="">
  16. <input type="submit" value="Submit" onClick="javascript:setDate()">
  17. </form>
  18. </body>
  19. </html>


...where process_form_date.php is...

php Code:
Original - php Code
  1.  
  2. <html>
  3. <head>
  4. <title></title>
  5. </head>
  6. <body>
  7. <p>Your form was submitted on
  8. <?php
  9.     // Script to handle form_date3
  10.     echo $_GET['localDate'];
  11. ?>
  12. </body>
  13. </html>


I hope some of you find this useful!

Reply With Quote
  #3  
Old November 13th, 2004, 03:44 AM
rehfeld_dot_us rehfeld_dot_us is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Posts: 825 rehfeld_dot_us User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Getting the Date from a client's machine

you can also do it without requiring them to submit a form


Code:

<head>
<script type="text/javascript">
var now = new Date();
var tzo = now.getTimezoneOffset();

document.write('<link rel="stylesheet" href="collect.php?tzo='+tzo+'" />');
</script>
</head>


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Getting the Date from a client's machine


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway