Page 1 of 1

converting unix timestamps in shortcode

PostPosted: June 4th, 2011, 12:16 am
by doctorproctor
I want to convert the EOT timestamp into a normal date, ideally using shortcode to keep it simple. In another thread, you alluded to the possibility of converting a UNIX timestamp via PHP; can this work in conjunction with an s2 shortcode on a page?

I'm new to this, but it looks like in order to execute PHP within a WP page we need to use a plugin such as Shortcode Exec PHP. The PHP side of it is pretty simple, but can one execute a shortcode inside another shortcode in WordPress? I'd appreciate a simple example using

[s2Get user_option="s2member_auto_eot_time" /]

as my PHP script is not quite working yet. (I've got this nested inside an [s2If] statement.)

Thanks!

Jim

Re: converting unix timestamps in shortcode

PostPosted: June 4th, 2011, 12:17 am
by Cristián Lávaque
This may help you viewtopic.php?f=36&t=1604 :)

Re: converting unix timestamps in shortcode

PostPosted: June 6th, 2011, 8:01 pm
by doctorproctor
Thanks for the quick reply! Just took a look, and this seems to work for PHP inside an s2 shortcode, but what I need is the reverse, i.e. shortcode supplies date inside Unix to PHP date function, e.g. "Your membership expires on <?php echo date('l F jS, Y','[s2Get user_option="s2member_auto_eot_time" /]') ?>." I can insert a literal Unix date in the above and it works fine, but the shortcode generates errors.

Thanks,

Jim

Re: converting unix timestamps in shortcode

PostPosted: June 7th, 2011, 2:07 am
by Cristián Lávaque
Ah, ok Jim, I see now what you are trying to do. Sorry I didn't understand the first time. Try this:

Code: Select all
echo date('l F jS, Y'get_user_option('wp_s2member_auto_eot_time'$user_id)); 


http://codex.wordpress.org/Function_Ref ... ser_option

I hope that helps. :)

Re: converting unix timestamps in shortcode

PostPosted: June 7th, 2011, 10:48 am
by doctorproctor
This works! Thank you.

Jim

Re: converting unix timestamps in shortcode

PostPosted: June 7th, 2011, 11:28 am
by Cristián Lávaque
Cool. :)