• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reformat date from CURRENT_TIMESTAMP

(02-24-2020, 08:29 AM)MikiStoni Wrote:
(02-23-2020, 09:47 PM)John_Betong Wrote: @MikiStoni,
> unfortunately not. the parser seems not to be able to read the date correctly

I am not a fan of using any parser and have never heard an argument that has convinced me to change my mind.

Try the following:

  <th scope="row">
    <?php date('d.m.y H:i:s', $timestamp); ?>

is surely a matter of taste. i like to use parsers. for me it is more tidy. i create an array and pass it to the template. the foreach and formatting is done in the template. i always used smarty. and with ci4 i wanted to eliminate smarty. but simple functions like formatting date or substr functions are unfortunately not supported.

by the way, your code does not work, because i pass the data as an array. variables in parser are only readable with brackets {}

I assumed that the $timestamp variable was an actual UNIX timestamp (integer seconds since 1970...) and not a string. 

Please try the following:
// or 
echo gettype($timestamp); 

Perhaps renaming $timestamp to $datetime would be easier for others when the variable types are not declared in the function parameters. Reminds me of calling apples oranges and vice-versa Smile
download and make your system directory strict

Hi zahhar

doesn't work for me.

My Controll

    // get ma permission name
    $data = [
      'ma_perm_name'          => permission2name(session('userData.permission')),
      'breadcrump_nav_big'    => 'Mein Profil',
      'breadcrump_nav_low'    => 'Profile',
      'changetable'           => changetable_get(session('userData.id'), 'changetable'),

    // view template
    echo $parser->setData($data)->renderString(view('profile'));

My Profile


                    <th scope="row">{timestamp|date(d.m.Y H:i:s)}</th>


My Helper

if (!function_exists('changetable_get')) {
    * Get changes in changetable table
    function changetable_get($ma, $table) {

        // get log
        $db       = \Config\Database::connect();
        $builder  = $db->table($table);
        $builder->orderBy('timestamp', 'DESC');
        $query    = $builder->get(50);

        return $query->getResult();




{changetable} {/changetable}
{timestamp|date(d.m.Y H:i:s)}     {message}

funny thing Smile

(02-26-2020, 04:08 AM)MikiStoni Wrote: Hi zahhar

doesn't work for me.

{changetable} {/changetable}
{timestamp|date(d.m.Y H:i:s)}     {message}

funny thing Smile

MikiStoni, this is how you could proceed:
1) ensure you have changes in system/View/Parser.php class as proposed here: https://github.com/codeigniter4/CodeIgni...2603/files
2) take my example and ensure it works for you. You should start wikth smth really simple.

Regarding your code: it most probably would not work. In order to work, you should populate {changetable} variable with array of arrays.
You can try the following: try to supply static data into changetable variable in your $data array first, like this:

PHP Code:
'changetable' => [
                   ['message' => 'My message''timestamp' => '2020-02-26 00:00:00']

Then show what you get.

Thumbs Up 
You're right. If I input that directly, it works.

with the further use of the class i found out that no provided filter works for me if a bracket belongs to it.


                    <td>{ message|prose }</td>
                    <td>{ message|capitalize }</td>
                    <td>{ message|abs }</td>

does not work:

                    <td>{ message|limit_chars(100) }</td>
                    <td>{ message|limit_words(20) }</td>
                    <td>{ message|number_format(3) }</td>

does anyone know the problem?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.