timestamp format

Questionstimestamp format
Ed K asked 8 years ago

Timestamp data types in DB2 are formatted as:

2016-11-22-14.56.18.376000

What is the correct srcformat to get this to display with the datetime picker? Trying this does not work:

$col["formatter"] = "datetime";
$col["formatoptions"] = array("srcformat"=>'Y-m-d-H.i.s',"newformat"=>'Y-m-d H:i',"opts" => array("timeFormat"=>"HH:mm"));

3 Answers
Abu Ghufran answered 8 years ago

You can try srcformat as Y-m-d-h.i.s.u
I've not tested it, feel free to contact back if it does not work.

source: http://stackoverflow.com/questions/12654051/db2-timestamp-php-datetime

Michael K. answered 8 years ago

Still not working:

$col["formatter"] = "datetime";
$col["formatoptions"] = array("srcformat"=>'Y-m-d-H.i.s.u',"newformat"=>'Y-m-d-H.i.s.u');

Produces the following results:

2016-12-21-14.02.16.000000 => 0000-12-21-02.16.00.000000
2016-12-21-11.44.01.000000 => blanks

It's interpreting the minutes position as hours, and not interpreting the year at all.

Abu Ghufran answered 8 years ago

Resolved via email. Pasting for reference.

$sqlCommand = "
select a.*, (substr(char(A.TIME_LM),1,10) concat ' ' concat substr(char(A.TIME_LM),12,8)) time_char , (substr(char(A.TIME_LM),1,10) concat ' ' concat substr(char(A.TIME_LM),12,8)) time_char2
from ……………….
";

$col = array();
$col["name"] = "TIME_CHAR2";
$col["title"] = "Last modified time";
// $col["hidden"] = true;
$col["formatter"] = "datetime";
$col["formatoptions"] = array("srcformat"=>'Y-m-d H.i.s',"newformat"=>'Y-m-d H.i.s');
$col["width"] = 500 ;
$col["dbname"] = "(substr(char(A.TIME_LM),1,10) concat ' ' concat substr(char(A.TIME_LM),12,8))";
$cols[] = $col;

Your Answer

17 + 9 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?