Home › Forums › Ticket Products › Event Tickets Plus › Need the event start date in specific format – implementing countdown
- This topic has 4 replies, 3 voices, and was last updated 9 years, 5 months ago by
Gergana.
-
AuthorPosts
-
November 2, 2016 at 9:50 am #1186445
Gergana
ParticipantHi,
I am implementing inside the ticket area of each event – smartcountdown shortcode. By so each ticket has a countdown for the sales end date. This is done by implementing the code down below into the ticket.php file (which is placed in my child-theme
$ticketenddate = $ticket->end_date; if ( !empty($ticket->end_date) ) { echo do_shortcode( '[smartcountdown deadline="' .$ticketenddate. '" fx_preset="Sliding_text_fade.xml" digits_style="font-family:Lucida Sans Unicode, Lucida Grande, sans-serif;font-weight:lighter;font-size:small;" digits_size="13" title_before_down="" mode="countdown" units="days,hours,minutes,seconds"]' );I need to get the start event date in this format (example 2016-10-29 18:30:00 ) for the same reasons as the described above.
What I’ve found until this moment is this
tribe_get_start_date();
but does not returns the format which I need (it returns – ноември 30 @ 10:00 am)Can you lead me to the way how to get the event date in this format 2016-10-29 18:30:00?
November 2, 2016 at 5:57 pm #1186741George
ParticipantHey Gergana!
Thanks for reaching out.
Customizing the date format is _possible_ but will require some tinkering with code and with PHP date formats.
Just to put the disclaimer out early and set expectations here, we unfortunately cannot help with code customizing, tweaking, tinkering, etc., as elaborated upon in our support policy here.
With that being said, I’m happy to try and at least get you started here! 😀
The important thing to keep in mind with getting tribe_get_start_date to show a specific date format is that the third argument it accepts is the date format — you can define this using the standard PHP date format operators and it should work well!
So, to elaborate:
• The first argument for tribe_get_start_date is the event ID of the event whose start date you’re getting
• The second argument is simply true or false: true if you want the “time” to show in addition to date, false if not. It defaults to true.
• The third argument is the PHP-style date format string which will be the format of the generated date.Here’s an example:
echo tribe_get_start_date( $event_id, true, 'm-d-Y h:i:s' );
☝️ That should get the date of the passed event in the “2016-10-29 18:30:00”-style format you described here.To learn more about that ‘m-d-Y h:i:s’ string in the example code, what it means, and how to tinker with it yourself, check out the PHP date formatting basics here ? http://php.net/manual/en/function.date.php
I hope this helps!
GeorgeNovember 3, 2016 at 3:41 am #1186902Gergana
ParticipantThank you George,
I have modified and it was in big use of my implementation.
November 3, 2016 at 10:36 am #1187179George
ParticipantGlad to hear it! 😀
Best of luck with your project,
George -
AuthorPosts
- The topic ‘Need the event start date in specific format – implementing countdown’ is closed to new replies.
