I'm trying to create a countdown timer that uses datetimes from a database.

So far I have the endDate as a DateTime object. What I want to be able to do is pass this into javascript as a javascript DateTime, then find the difference between the endDate and Now, and countdown the days, hours, minutes, seconds until the endDate datetime then stop.

So how do i get a PHP datetime object into javascript as a js datetime.

Aeterna,

PHP will write javascript within <script></script> tags in exactly the same way it writes HTML within <html></html> tags.

You need to do some string handling to write the arguments of a javascript Date invocation. See here.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.