cdub
cdub

Reputation: 25711

Javascript getTime to php date

I have javascript that turns dates in my view to a time string using getTime(). That then is stored as a value for an option in my select form. Once it is passed to php, how do I turn that into a php date?

I have done:

echo date("m/d/Y", '1345618799000');

1345618799000 = Tue Aug 21 2012

Upvotes: 6

Views: 6144

Answers (2)

John V.
John V.

Reputation: 4670

You use PHP's date() function:

date("Format here (see documentation)", round($_POST["time_field"]/1000));

Updated, thanks Yoshi.

Upvotes: 9

Vishal
Vishal

Reputation: 1234

You may use PHP's strtotime() to change any string into a Unix timestamp; strtotime()

Upvotes: 0

Related Questions