• Resolved tcushing

    (@tcushing)


    I am retreiving the meta data in a custom field in my posts with the following code:

    <?php echo get_post_meta($post->ID,'upcomingeventdate', true) ?>

    In each post, I am entering in the custom field a date, for example 20101130, which is displayed as such at the end of each post. What I want is for the date to be displayed in a customary way such as 11/30/2010.

    I would appreciate it if anyone code help with the code or direct me to where I can read how to do it. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Why not put it in as 11/30/2010?

    The only parse I can think of is if you used the unix time and parsed that.

    Thread Starter tcushing

    (@tcushing)

    If I enter the data as 11/30/2010. My posts do not appear. I am using the following code to select particular posts and order them:

    $querystr = "
    
        SELECT wposts.*
    
        FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
    
        WHERE wposts.ID = wpostmeta.post_id
    
        AND wposts.post_status = 'publish'
    
        AND wposts.post_type = 'post'
    
        AND wpostmeta.meta_key = 'upcomingeventdate'
    
        AND wpostmeta.meta_value > NOW()   
    
        ORDER BY wpostmeta.meta_value asc
    
     ";
    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Oh I see. It’d probably work if you did 2010.11.30 but yeah.

    Maybe this…

    $originalDate = "20100321";
    $newDate = date("m/d/Y", strtotime($originalDate));

    You’ll have to sort out how to pull in the upcomingeventdate into the originalDate bit, but in theory that could work.

    Thread Starter tcushing

    (@tcushing)

    Awesome! I got it. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Field as customary date?’ is closed to new replies.