WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom date not showing correctly when using date_i18n (4 posts)

  1. Sebastien D
    Member
    Posted 1 year ago #

    I am unable to display a custom date using date_i18n

    It will only display the date and time of now.

    For example, I have a date of 2013-07-29 15:07:25 but I get 2013-07-30 15:37:06

    $date = '2013-07-29 15:07:25'
    echo date_i18n('D j M, Y g:i:s a', strtotime($date))

    If I was to do date_i18n('D j M, Y g:i:s a', strtotime($post->post_date)) it would work fine but not a custom date from let's say a post meta value.

    Any help to get this working or show what I am doing wrong would be most appreciated.

    Thank you.

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    Can we see the full code with the post meta value? What is the format of the meta value (YYYY-MM-DD)?

  3. Sebastien D
    Member
    Posted 1 year ago #

    The date and time is in two separate post meta keys.

    One for the date and one for the time.

    The date is formatted like so: YYYY-MM-DD

    The time is formatted like so: HH:MM:SS = 15:07:25

  4. Sebastien D
    Member
    Posted 1 year ago #

    I have solved the problem.

Topic Closed

This topic has been closed to new replies.

About this Topic