Hey men, i am by using this script (http://snipplr.com/view/4912/relative-time/) to produce relative occasions using PHP and timestamps saved during my database. I am while using standard format for storing datetime (eg 2010-05-07 20:26:17) and delay pills work fine with any timestamps i create.
But for whatever reason after i use a timestamp saved in wordpress's wordpress_posts table, the function fails and returns "The month of january 1, 1970". I can not use whatever difference within the format of wordpress' timestamps and my very own. And that i may use wordpress' data fine while using date() function to provide a formatted date, simply not a family member time using my very own function.
If you're able to make use of the dates fine with
date() then you definitely most likely ask them to in UNIX timestamp format already. Try getting rid of the
strtotime() calls in
getRelativeTime() (online 7 and 22).
You do not need that script - WordPress includes a human time difference function you should use
To print an entry's time ("a couple of days ago"):
<?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?>
<?php echo human_time_diff(get_comment_time('U'), current_time('timestamp')) . ' ago'; ?>