1

I'm very new to WordPress. I need to get the date of a post and compare that date to a specific date (04/01/2011), so add some banners and stuff to every post created "after" that pivot date. But the only functions I found in the wordpress documentation are examples of functions to "print" the date, like the_time(), etc.

Anyone knows how I could made this thing?

Thanks in advance!!!

2 Answers 2

4

get_the_date and/or get_the_time will return the date/time of the post rather than printing it.

2
  • Some sample would be appresiated...
    – user4634
    Apr 13, 2011 at 14:32
  • @Nathan The function names in my answer are links to the WordPress codex pages for these functions. Those pages include the sample/default code on their use.
    – Manzabar
    Apr 13, 2011 at 16:08
1

just use the following code

<?php echo the_time(get_option('date_format'));?>

to get the time in any of wordpress page if you want to get the date then use just the following code

<?php echo the_date(get_option('date_format'));?>

i think that code solve the problem. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.