views:

66

answers:

2

How can i get current date from server-side (such as new Date from server date time not from client'computer date), when i use jQuery datepicker?

Do i need get time from server and pass it to the js code? How can i do it. i am using classic asp

+2  A: 

If you only care about the date you can simply add the date to a javascript variable when you are creating the page. Something like the following

<script type="text/javascript">
  var date = <%=date()%>;
</script>

Just use that date var to set the date for the datepicker.

Jeff Beck
This is client-side, and may not match the server, for example...roll back your clock, or live in across the international dateline.
Nick Craver
The <%=date()%> is asp code which would be server side.
Jeff Beck
it doesn't work
Jason
What isn't working for you? The ASP?
Jeff Beck
+1  A: 

This is a little approach.

Step 1: Create an hidden input field anywhere on the page..

<input type="hidden" name="mydate" value=""/>

Step 2: Insert the php date code in the value attribute..

<?php echo date('D, d, Y') ?>

Step 3: now use jquery to get the value of this field and assign it to a variable..

finished

joberror
Question was for asp
Jeff Beck