KateMacwil Posted June 13, 2018 Share Posted June 13, 2018 Hi I am would like to display the date as "Jan. 3, 2018" (example). I have tried a few variations of trying to format my date field to the above and nothing is wokring for me. <?php $sEventDate = get_post_meta (get_the_ID(), "meta-text2", true); if ($sEventDate) { echo "<div style=font-size: 14px;'>Event Date: $sEventDate</div>"; } else { echo "<div style=font-size: 14px;'>Event Date: --</div>"; } ?> Link to comment Share on other sites More sharing options...
dsonesuk Posted June 13, 2018 Share Posted June 13, 2018 This should ideally be a question on a wordpress forum. You need to specify the format required https://www.w3schools.com/php/func_date_date.asp echo '<div style="font-size: 14px;">Event Date: '.date('M, n, Y', strtotime($sEventDate)).'</div>'; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now