tags:

views:

38

answers:

2

Hi,
I need to check what’s the current date where the user is in.
I don’t need the time, just the current date.
How can i do it?
I'm using codeigniter.
Thanks.

A: 

The web server and, by extension, your application do not have this information. You have to get that input from the client side somehow. A couple of ideas come to mind:

  • Ask the user what time zone they're in (e.g., with a form), then calculate their date based on that.
  • Use some JavaScript that finds the information automatically (e.g., getTimezoneOffset()). Optionally, submit this information to your app via Ajax.
Jeff
Can you point me to some examples so i can learn how to do it?
JEagle
Here's an example of using jQuery Ajax with CodeIgniter: http://www.mrforbes.com/thoughts/2009/01/28/a-quick-code-igniter-and-jquery-ajax-tutorial/ - basically you want a controller that will accept the user's data (including user id, time zone, date, or whatever other information you want to pass to the server). Also see the various jQuery Ajax methods here: http://api.jquery.com/category/ajax/
Jeff
@Jeff thanks for the links. Will try to get it right since i'm still a newbie in jQuery...
JEagle
A: 
JEagle
just can't get the code right, if someone could help me i'll appreciate it.
JEagle