european format for <OTRS_TICKET_Created>

Moderator: crythias

Post Reply
mmmatty
OTRS newbie
Posts: 10
Joined: 27 Nov 2013, 14:14
OTRS Version?: 3.3.1

european format for <OTRS_TICKET_Created>

Post by mmmatty » 27 Nov 2013, 14:30

Hi! i want to know how to set european format for the <OTRS_TICKET_Created> variable. I use it into the auto reply's body email to customer after a new ticket creation.
The format is yyyy-mm-dd, and what i want is dd-mm-yyyy, and if it's possible i don't want to see the seconds (now is hh:mm:ss, i want hh:mm).
I tried to edit Kernel/System/Time.pm, but after modifying that file, the OTRS' error log gives me a lot of "Invalid time format '27-11-2013 12:29:17'!" error in OTRS-CGI-01 function.

Thanks & regards!

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: european format for <OTRS_TICKET_Created>

Post by crythias » 27 Nov 2013, 14:54

To do what you want would probably require modifying Kernel/System/Ticket.pm ...

something like:

Code: Select all

    $Ticket{myCreated} = $Self->{TimeObject}->SystemTime2TimeStamp(
        SystemTime => $Ticket{CreateTimeUnix},
        MyFlag => '1',
    );
and then in Time.pm:

Code: Select all

   if ( $Param{MyFlag} && $Param{MyFlag} eq '1' ) {
 return "$Day-$Month-$Year $Hour:$Min";
}
<OTRS_TICKET_myCreated>

This won't survive updates and has been coded without testing, but generally copied from existing code, which you probably could figure out where to place near likeminded code.
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask

mmmatty
OTRS newbie
Posts: 10
Joined: 27 Nov 2013, 14:14
OTRS Version?: 3.3.1

Re: european format for <OTRS_TICKET_Created>

Post by mmmatty » 27 Nov 2013, 16:13

oh very nice! it works!

the only problem is that in OTRS' error log:

Wed Nov 27 15:12:07 2013 notice OTRS-CGI-01 Run GenericAgent Job 'xxx' from db.
Wed Nov 27 15:12:07 2013 error OTRS-CGI-01 Need Time!
Wed Nov 27 15:12:07 2013 error OTRS-CGI-01 Need String!
Wed Nov 27 15:12:06 2013 notice OTRS-CGI-01 Run GenericAgent Job 'xxx' from db.
Wed Nov 27 15:12:06 2013 notice OTRS-CGI-01 Run GenericAgent Job 'xxx' from db.
Wed Nov 27 15:12:06 2013 info OTRS-CGI-01 Sent agent 'NewTicket' notification to 'xxx'.

where xxx are my tasks for generic agent, and the escalation time for ticket is null.
Where's the problem?

edit: I've found my error! i have to ADD "myCreated" entry in Ticket.pm, and not to modify the existent "Created".
In Ticket.pm

Code: Select all

Returns:

    %Ticket = (
        TicketNumber       => '20101027000001',
        Title              => 'some title',
        TicketID           => 123,
        State              => 'some state',
        StateID            => 123,
        StateType          => 'some state type',
        Priority           => 'some priority',
        PriorityID         => 123,
        Lock               => 'lock',
        LockID             => 123,
        Queue              => 'some queue',
        QueueID            => 123,
        CustomerID         => 'customer_id_123',
        CustomerUserID     => 'customer_user_id_123',
        Owner              => 'some_owner_login',
        OwnerID            => 123,
        Type               => 'some ticket type',
        TypeID             => 123,
        SLA                => 'some sla',
        SLAID              => 123,
        Service            => 'some service',
        ServiceID          => 123,
        Responsible        => 'some_responsible_login',
        ResponsibleID      => 123,
        Age                => 3456,
        Created            => '2010-10-27 20:15:00'
        myCreated      => '27-10-2010 20:15'
        CreateTimeUnix     => '1231414141',
        CreateBy           => 123,
        Changed            => '2010-10-27 20:15:15',
        ChangeBy           => 123,
        ArchiveFlag        => 'y',

Code: Select all

$Ticket{Created} = $Self->{TimeObject}->SystemTime2TimeStamp(
        SystemTime => $Ticket{CreateTimeUnix},
    );
$Ticket{myCreated} = $Self->{TimeObject}->SystemTime2TimeStamp(
        SystemTime => $Ticket{CreateTimeUnix},
	   MyFlag => '1',
    );
and in Time.pm

Code: Select all

 # check needed stuff
    if ( !$Param{SystemTime} ) {
        $Self->{LogObject}->Log( Priority => 'error', Message => 'Need SystemTime!' );
        return;
    }

    my ( $Sec, $Min, $Hour, $Day, $Month, $Year ) = $Self->SystemTime2Date(%Param);
    if ( $Param{Type} && $Param{Type} eq 'Short' ) {
        my ( $CSec, $CMin, $CHour, $CDay, $CMonth, $CYear ) = $Self->SystemTime2Date(
            SystemTime => $Self->SystemTime(),
        );
        if ( $CYear == $Year && $CMonth == $Month && $CDay == $Day ) {
            return "$Hour:$Min:$Sec";
        }
        return "$Year-$Month-$Day $Hour:$Min:$Sec";
    }
    if ( $Param{MyFlag} && $Param{MyFlag} eq '1' ) {
        return "$Day-$Month-$Year $Hour:$Min";
    }
    return "$Year-$Month-$Day $Hour:$Min:$Sec";
}

User avatar
crythias
Moderator
Posts: 9980
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: european format for <OTRS_TICKET_Created>

Post by crythias » 27 Nov 2013, 16:38

Great to hear!

Also, and this is just a "in case you're adventurous", the Ticket myCreated parameter is globally usable for all *frontend* places you'd use Created (like stats). (You may have to add the field in SysConfig or modify .dtls, but ...)
obviously, not backend...
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask

Snowmanko
OTRS newbie
Posts: 45
Joined: 06 Mar 2015, 17:45
OTRS Version?: 6.0.5-1

Re: european format for <OTRS_TICKET_Created>

Post by Snowmanko » 17 Apr 2018, 11:06

Hi,

do you know how to implement european datetime format in OTRS 6 ?

Thanks.
OTRS 6.0.3-1, MySQL

Snowmanko
OTRS newbie
Posts: 45
Joined: 06 Mar 2015, 17:45
OTRS Version?: 6.0.5-1

Re: european format for <OTRS_TICKET_Created>

Post by Snowmanko » 24 Apr 2018, 15:13

Anyone ?
OTRS 6.0.3-1, MySQL

Post Reply