Current location: Hot Scripts Forums » General Web Coding » JavaScript » Get Server Date in JavaScript


Get Server Date in JavaScript

Reply
  #1 (permalink)  
Old 01-25-06, 05:16 AM
studenteye's Avatar
studenteye studenteye is offline
Newbie Coder
 
Join Date: Jul 2004
Location: UK
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Get Server Date in JavaScript

Hi,

I have created a pop up Calendar as a date input picker for my site.

but calendar shows client's machine dates.

how i can get dates from server ?

Thanks
Reply With Quote
  #2 (permalink)  
Old 01-25-06, 11:58 AM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Well since javascript is client side, to get the server date you are going to have to use some kinda server side script(i.e. php, asp).
__________________
:: ImperialBB :: New version in the works! :: http://www.imperialbb.com ::

:: Have a question about the board? The Rules? An Infraction/Warning? :: Contact Form ::
Reply With Quote
  #3 (permalink)  
Old 01-25-06, 03:52 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Here is a script that gets the server's time. You can probably study this and expand it to include the server's date -
http://www.dynamicdrive.com/dynamicindex6/localtime.htm

P.S. This script includes a "long" switch that gives the date as well.

Last edited by mab; 01-25-06 at 03:59 PM.
Reply With Quote
  #4 (permalink)  
Old 01-25-06, 09:08 PM
koncept
Guest
 
Posts: n/a
mab that will not work as deap-poetic has pointed out javascript is client side. the script you posted has server side calls embeded in javascript which get the servers date and time.

in short there is no way to get a servers date and time in pure javascript
Reply With Quote
  #5 (permalink)  
Old 01-26-06, 07:25 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
This is interesting!

http://www.worldtimeserver.com/time_...ide/#component

I didn't read it all, but it seems like you can run javascript on serverside, using

Code:
RUNAT="SERVER"
Reply With Quote
  #6 (permalink)  
Old 01-26-06, 10:11 AM
koncept
Guest
 
Posts: n/a
http://en.wikipedia.org/wiki/JavaScript
http://en.wikipedia.org/wiki/Client-side_JavaScript
http://en.wikipedia.org/wiki/Server-side_JavaScript

Yes Nico you are correct the script tag can be set to runat the server level, but then to my knowledge it becomes jscript (server side javascript)
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
retieveing selected date from a calendar popup using javascript into datetext field yusufoladele JavaScript 1 11-27-06 04:43 AM
Free web site, control panel, and dedicated IP with game server purchase for only $25 twastudios General Advertisements 3 10-20-05 06:13 AM
Javascript Server connection vincentdehaan JavaScript 1 06-04-05 07:18 AM
server date go to ddesign JavaScript 0 11-09-04 09:19 AM
Saving changes made by a javascript to the server Leanne JavaScript 7 01-08-04 11:57 AM


All times are GMT -5. The time now is 11:02 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.