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 8379519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:12:41+00:00 2026-06-09T16:12:41+00:00

Here is my function, and the date $data->datecreated = getdate(); at the bellow code

  • 0

Here is my function, and the date

$data->datecreated = getdate(); 

at the bellow code won’t get saved in the database. Why?
Notice that the record gets inserted, but the datecreated field looks like is ignored

public function generateCode($characters) {

        //Generate the code
        $possible = '23456789bcdfghjkmnpqrstvwxyz';
        $code = '';
        $i = 0;

        while ($i < $characters) {
            $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
            $i++;
        }
        // Get the curent session id of the user        
        $session =  JFactory::getSession();
        $session_id = $session->getId();        

        //Create an stdClass
        $data =new stdClass();
        $data->sessionid = (integer)$session_id;
        $data->captchacode = (string)$code;     
        $data->datecreated = getdate();

        $db = JFactory::getDBO();

        $query = $db->getQuery(true);
        $query->delete($db->nameQuote('#__captchasessions'));
        $query->where($db->nameQuote('sessionid').'='.$db->quote($session_id));
        $db->setQuery($query);
        $db->query();

        $db->insertObject( '#__captchasessions', $data, id );       

        return $code;
    }

This is the structure of the table

delimiter $$

CREATE TABLE `ok6ut_captchasessions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sessionid` varchar(200) DEFAULT NULL,
  `captchacode` varchar(10) DEFAULT NULL,
  `datecreated` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8$$
  • 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-09T16:12:43+00:00Added an answer on June 9, 2026 at 4:12 pm

    getdate() returns an array with details of the current date in it, if there’s no timestamp passed in as a parameter.

    I expect that your database is expecting a formatted date to be passed in, and not an array – if you could add your database structure, that might help.

    Edited to add:

    For a datetime field, I think you need something like:

    $data->datecreated = date("Y-m-d H:i:s");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a code of FullCalendar that I am using: $(document).ready(function() { var date
I've got a function here that is meant to look through a list of
simonn helped me to code an ordered integer partition function here. He posted two
I have the middleware that allows me to check user auth, here is: function
Here is what I am getting as data: jsonp1290537545248( [{Active:true,EndDate:\/Date(-62135578800000-0500)\/,StartDate:\/Date(1280635200000-0400)\/}] ); $.getJSON(url, {}, function
I am writing this code. Here dt is input into the function, as well
Here is a snippet of my html: <input id=btnGetDate type=submit value=Get Date /> <div
I have two functions here function Preloader() {} Preloader.prototype = { init:function() { //
I have a simple Jquery function here: function submit_selection(del,submit) { del='yes'; submit=true; var ITAMZ=new
Here is function , <script type=text/javascript> $(document).ready(function() { getRecordspage(1, 5); $(a.page-numbers).click(function() { alert(1); getRecordspage($(this).text(),

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.