This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Change "date_created" format (Germany/Deutschland)


  1. nilsmierzynski
    Member

    Hi!

    I love to change the format of the date_created variable.
    Is it just to change the this line in "post-functions.php"?

    line 927: $table_data['date_created'] = date("Y-m-d H:i:s");

    to German standard:

    line 927: $table_data['date_created'] = date("d.m.Y H:i:s");

    or are other file affected or will cause problems?
    Thank you!
    Nils

    Posted 17 years ago #
  2. redityo

    Hi,

    I'm afraid you can not directly change date format in mySQL database, since mySQL using YYYY-MM-DD format for date type. But you can get your format in view entries and excel export, to do this you should edit "view_entry.php" and "export_entries.php" files.

    1. Edit view_entry.php, search around line 51, you'll see this code :

    $query = "select date_created,date_updated,ip_address from ~ap_form_{$form_id}~
    where id='$entry_id'";

    replace with this one

    $query = "select date_format(date_created,'%d.%m%.%Y %H:%i:%s')
     date_created,date_updated,ip_address from ~ap_form_{$form_id}~ where id='$entry_id'";

    2. Edit "export_entries.php", search around line 324 you'll see this code

    $form_data[$i][$j] = $row[$column_name];

    replace with

    if ($column_name == 'date_created')
    	$form_data[$i][$j] =date("d.m.Y H:i:s",strtotime($row[$column_name]));
    else
    	$form_data[$i][$j] = $row[$column_name];

    MachForm Support

    Posted 17 years ago #
  3. nilsmierzynski
    Member

    Hi redityo!

    Thank you. Doing this changes in the code of this two file cause this error:

    select date_format(date_created,'%d.%m%.%Y %H:%i:%s') date_created,date_updated,ip_address from ap_form_2 where id='525' Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ap_form_2 where id='525'' at line 1

    This is what I did:

    view_entry.php
    $query = "select date_created,date_updated,ip_address fromap_form_{$form_id}where id='$entry_id'";

    $query = "select date_format(date_created,'%d.%m%.%Y %H:%i:%s') date_created,date_updated,ip_address from <code>ap_form_{$form_id}</code> where id='$entry_id'";

    and

    export_entries.php

    $form_data[$i][$j] = $row[$column_name];

    if ($column_name == 'date_created')
    						$form_data[$i][$j] =date("d.m.Y H:i:s",strtotime($row[$column_name]));
    					else
    						$form_data[$i][$j] = $row[$column_name];

    What did I wrong?
    Rechanged everything with success.

    Thank you for your perfect support!
    Nils

    Posted 17 years ago #
  4. redityo

    Hi Nils,

    Sorry .. since this forums can not use "backticks" it show different result. However I've update my post, please replace ~ character to "backticks" character when you copy those code to your machform file.


    MachForm Support

    Posted 17 years ago #
  5. nilsmierzynski
    Member

    Hi redityo!

    Works great!
    Just replaced the ~ in your code...
    ~ap_form_{$form_id}~
    to the "backticks" and it worked fine!

    Thank you!
    Nils

    Posted 17 years ago #
  6. antoniovarrina
    Member

    This dont work for me...

    I got error

    select date_format(date_created,'%d.%m%.%Y %H:%i:%s') date_created,date_updated,ip_address from 'ap_form_1' where id='13' Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''ap_form_1' where id='13'' at line 1

    Posted 15 years ago #
  7. antoniovarrina
    Member

    Now i fix that, but Parse error: parse error in ''C:\wamp\www\o\view_entry.php on line 51''

    ....

    Posted 15 years ago #
  8. yuniar

    Can you send us your file please? We'll check it.
    Please send to: customer.service [at] appnitro.com


    MachForm Founder

    Posted 15 years ago #

RSS feed for this topic

Reply