in reply to Re: Formatting MySQL's TIMESTAMP
in thread Formatting MySQL's TIMESTAMP

What I'm looking for is more on the lines of "%A %d %B %Y @ %I:%M%p %Z".

Replies are listed 'Best First'.
Re: Re: Re: Formatting MySQL's TIMESTAMP
by dempa (Friar) on Mar 21, 2002 at 09:32 UTC
    Well, apart from the timezone that would in DATE_FORMAT syntax equal:

    %W %d %M %Y @ %I:%i%p

    If you're willing to be a bit database-specific, use UNIX_TIMESTAMP to get the timestamp in epoch-format and then use POSIX::strftime to format your date.
    # epoch-date in $epoch use POSIX; my $formatted_date = POSIX::strftime("%A %d %B %Y @ %I:%M%p %Z",localtime($epoch));
    If you want to be as non db-specific as possible, take the advice below and forget UNIX_TIMESTAMP. Just select the timestamp-column and use appropriate date-manipulation module to convert it to epoch-format.
      Thanks that first option looks good enough for me. Guess I should have really looked at the manual first (lists all the codes).