Welcome Guest, Not a member yet? Register   Sign In
Reformat date from CURRENT_TIMESTAMP
#11

(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:

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


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:
Code:
var_dump($timestamp);
// 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
Reply


Messages In This Thread
RE: Reformat date from CURRENT_TIMESTAMP - by John_Betong - 02-24-2020, 11:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB