Jump to content

format output of javascript date object


chiprivers

Recommended Posts

In my current application, I am working with dates in the format 'YYYY-MM-DD HH:MM:SS'.  The main reason I am using this format is because it is the format stored in my MYSQL database.  I have had no problems working with this format in the PHP elements of my script, however I need some assistance with the javascript!

 

I need to be able to output a datetime string in the above format from my javascript date object.  In PHP it woudld be simple, $date->format('Y-m-d H:i:s'); but from what I can see with Javascript, you have to extract each portion of the date and time.  This wouldn't be such a problem if the numbers for months and days were prefixed with 0s where applicable!

 

Is there a straight forward function for this that I have missed somewhere?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.