Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8525575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:01:15+00:00 2026-06-11T08:01:15+00:00

When I retrieve a a column from my MySQL database (using mysql node module),

  • 0

When I retrieve a a column from my MySQL database (using mysql node module), I get a useless date formatted like:

Wed Sep 12 2012 08:44:26 GMT+0100 (GMT Daylight Time)

When I try to use the dateformat module on the returned result I simply get “Invalid date”.

I want the date to be formatted the way MySQL formats it i.e. YYYY-MM-DD HH:MM:SS

Here is my script:

var lastChanged = '' ;
var lastUpdated = '' ;
var poll ;
function DBPoller()
{
poll = setTimeout(function(){
    connection.query('SELECT enquiryAdded FROM _table_updates', function(e, row) {
        if(e)
        {
            console.log('An error occured: '+e)
        }
        else
        {
            addedDate = dateFormat(row[0], 'yyyy-mm-dd hh:MM:ss') ;
            if(addedDate != lastChanged)
            {
                console.log('An enquiry was just added at '+addedDate+', the one before this was at '+lastChanged) ;
                lastChanged = addedDate ;
            }
        }
    });
    DBPoller() ;
}, 2000)
}

The above gives me the “Invalid date” error.

What am I missing?


Hi, the mysql column datatype is DATETIME.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:01:16+00:00Added an answer on June 11, 2026 at 8:01 am

    I found it!

    The result from MySQL is a JSON string:

    { enquiryAdded: Wed Sep 12 2012 08:44:26 GMT+0100 (GMT Daylight Time) }
    

    So all I did was is access that value:

    var addedDate = dateFormat(row[0].enquiryAdded, ‘yyyy-mm-dd hh:MM:ss’) ;

    That’s why I was getting “Invalid date”!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to retrieve records from table by knowing the date in column contains
I am querying a mySQL database to retrieve the data from 1 particular row.
I want to get data from the database (MySQL) by JPA, I want it
My problem is rather straight-forward: Retrieve an image from a MySQL database (currently stored
I am using Rails 3.2.2 and I would like to retrieve records from the
I'm using this php to fetch data from my mysql database: $wpdb->get_var(select count(*) from
In order to retrieve rows from a table in a mysql database, where the
I am trying to retrieve a column from another related table, and display that
How to retrieve data from two tables whose column names are the same?
how to retrieve a single column's value of type string using HQL. I tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.