0

Is there a way to change the date and time in WordPress, not the timezone, but the date and time all together, like make it 03-21-85 11:11 PM. I want all dates and times to be changed, not just to one post or page, but to the whole WordPress site it's self.

7
  • Do you want to change the post time of one page/post? Or do you want every single date field to be subtracted with 30 years? Could explain a little bit more detailled what you want to achieve?
    – leymannx
    Commented Jun 19, 2014 at 16:16
  • Every single date field to be changed, I just used the date and time 03-21-85 11:11 PM as an example
    – Tom
    Commented Jun 19, 2014 at 16:17
  • When you edit/create an article/page you have the option to edit the post date by yourself. Would that be enough?
    – leymannx
    Commented Jun 19, 2014 at 16:18
  • No, I was looking for something that would change the php date function, I was wondering if I could change this through wordpress
    – Tom
    Commented Jun 19, 2014 at 16:19
  • I'm still curious why you want to do this...
    – leymannx
    Commented Jun 19, 2014 at 16:29

2 Answers 2

0

Maybe you'ld like to go to settings > general and then add a custom date format. Like d.m.1985 instead of d.m.Y

Or you write a function that subtracts the time you want from the current date.

Or you set the server time back to 1985. But that's no good idea since it will affect other apps, mysql etc. as well.

Last but not least you could try to set up a second development environment maybe in Virtualbox and then set the OS time manually.

4
  • I'm looking for a way to change the php date function it's self, I starting to think I can't change this through wordpress
    – Tom
    Commented Jun 19, 2014 at 16:37
  • Yeah I think so as well. But you could try to set up a second development environment maybe in virtualbox and then set the OS time manually.
    – leymannx
    Commented Jun 19, 2014 at 16:49
  • Great idea! That seems easy enough, thanks! (If you change your answer, I will mark it as "accepted answer")
    – Tom
    Commented Jun 19, 2014 at 16:51
  • @User - Done :D
    – leymannx
    Commented Jun 19, 2014 at 16:52
0

Edited because perhaps I misunderstood the question. the date_i18n filter is probably what you want.

add_filter( 'date_i18n', 'wwm_date_i18n' );

function wwm_date_i18n( $d = '' ) {

return '03-21-85 11:11 PM';
}

pics or it didn't happen:

pics or it didn't happen

original answer:

The WordPress pre_option_$option filter will do what you want.

add_filter( 'pre_option_date_format', 'wwm_date_format' );

function wwm_date_format( $d = '' )
{

 return 'm-d-y h:i A';
}

any time the_date() or get_the_date() are called, they will use this format for the date output.

7
  • Thank you for your response, I was looking for something that could take the php date function and return a specified date.
    – Tom
    Commented Jun 20, 2014 at 3:15
  • does the date_i18n filter snippet above not accomplish what you want?
    – Will
    Commented Jun 20, 2014 at 10:45
  • Yes, but I don't think that would change every date in WordPress, would it?
    – Tom
    Commented Jun 20, 2014 at 14:29
  • It's not going to change the actual values stored in the database, but all the dates will be displayed as '03-21-85 11:11 PM'. The code posted should not be used without adding some conditional logic or other trickery, as it will likely break database updates if used as is.
    – Will
    Commented Jun 20, 2014 at 14:47
  • So, in this plugin I made pastebin.com/ZQisJMPQ, will the date return as the date specified in the add_filter?
    – Tom
    Commented Jun 20, 2014 at 14:53

Your Answer

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

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