How to I get the date and time from SharePoint Server 2007 and pass this value as a Javascript variable?
|
No need to get it from SharePoint; use a content editor web part (CEWP) to get the date directly in JavaScript. Once you've dropped a CEWP on the page, click to add content, choose HTML > Edit HTML Source from the ribbon. Now put a JavaScript block in it: Something as simple as If you need to fetch the server time, you can a) use the Client Object Model to connect to the server via JavaScript; b) use some simple server-side code to fetch the system date on your master page or page layout and store it in a JavaScript variable:
Now you're using JavaScript client side and fetching the date from the system server side. You have it stored in a Date object in JavaScript so you can use the earlier example to manipulate it as needed. Ensure that server-side code blocks are enabled in your web.config for this to work. |
|||||||||||
|