SLEDGE
SLEDGE

Reputation: 63

System Time To Server with PHP and JS

What I'm trying to do, is to fill in a hidden input in a login/register page for a website, and inside that input will contain the JavaScript new Date() thing, like:

"Fri Mar 23 2012 22:23:03 GMT-0700 (PDT)"

I would like to take that information and use it server-side to convert it to the PHP date() and display it in the user's timezone.

It seems like there would be an easy way using the GMT difference of -0700, but I've looked all over and I can't find a way to simply plug that number in.

Is there an easy solution to this? All I want to do is modify the output to the users time after submitting the form.

Upvotes: 2

Views: 108

Answers (1)

dualed
dualed

Reputation: 10502

Use date_create_from_format() or a similar function. Make sure to output the date from Javascript in the same format you intend to read.

Also see this old answer from ... myself:

Upvotes: 1

Related Questions