wordpressdatetimetimewordpress-themingcurrent-time

Using Wordpress human_time_diff(current_time( 'timestamp' ) for time left calculation. How?


Building a solution on WP Job Manager and need a output for time left until job deadline. I have all the add ons active. I have set the expiry of job listing to 30 days. Now I need a function to call out and calculate the time difference between current time and the expiry date. Basically a time left to apply calculation.

This is what I have been working on:

printf( __( '%s left', 'wp-job-manager' ), human_time_diff(current_time( 'timestamp' ), get_job_field('job_deadline') ) );

However this only displays "1 min left" at all times, so it's not getting the job_deadline.

Biggest problem right now is that the form field where you can input a deadline is optional, but I plan to remove it completely and only leave the option at my own dashboard that all of the job listings expire in 30 days, but I can't find any way to reference the setting at my admin dashboard.

If someone has experience with WP Job Manager or can help without experience with the specific plugin(s).


Solution

  • <?php get_job_field('job_expires'); ?>
    

    I learned that this is the function that references to the default 30 day expiry, however it's not in UNIX format and that's what caused my problems during first testing phases

    Leaving the question/answer for future reference if someone will need it.