Title: Parse error: syntax error, unexpected T_STRING
Last modified: August 22, 2016

---

# Parse error: syntax error, unexpected T_STRING

 *  [cjohnson26](https://wordpress.org/support/users/cjohnson26/)
 * (@cjohnson26)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_string-62/)
 * Hi there,
 * I’ve had such a hard time with this one. I’m trying to adjust this:
 * $time_string = ‘<time class=”entry-date published” datetime=”%1$s”>%2$s</time
   >’;
 * to this
 * $time_string = ‘<?php echo relative_time(get_the_time(‘U’), current_time(‘timestamp’)).‘
   ago’; ?>’;
 * I’ve got coding in the function.php to grab how long ago the post was posted,
   but I the theme doesn’t have the template tags very easily done so I can’t simply
   replace the normal <?php the_time(); ?>
 * Let me know if you have any questions. Your help is much appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_string-62/#post-5608233)
 * Hi cjohnson26
 * Can you show us the printf or sprintf function that is used with the `$time_string`
   variable.
 * I’m guessing the relative_time() function is similar to the WordPress human_time_diff()
   function.
    [http://codex.wordpress.org/Function_Reference/human_time_diff](http://codex.wordpress.org/Function_Reference/human_time_diff)
 *  Thread Starter [cjohnson26](https://wordpress.org/support/users/cjohnson26/)
 * (@cjohnson26)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_string-62/#post-5608287)
 * Hey keesiemeijer!
 * Yeah, it’s a variation of the human_time_diff() – I just changed the name so 
   it wouldn’t clash with the original coding.
 * Here’s the full code for that section:
 * function themememe_posted_on() {
    $time_string = ‘<time class=”entry-date published”
   datetime=”%1$s”>%2$s</time>’;
 *  $time_string = sprintf( $time_string,
    esc_attr( get_the_date( ‘c’ ) ), esc_html(
   get_the_date() ), esc_attr( get_the_modified_date( ‘c’ ) ), esc_html( get_the_modified_date()));
 *  printf( __( ‘<span class=”byline”><i class=”fa fa-user”></i>%1$s</span><span
   class=”posted-on”><i class=”fa fa-calendar”></i>%2$s</span>’, ‘themememe’ ),
   
   sprintf( ‘<span class=”author vcard”>[%2$s](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_string-62/%1$s?output_format=md)
   </span>’, esc_url( get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ), esc_html(
   get_the_author() ) ), sprintf( ‘<!–[–>%2$s<!–](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_string-62/%1$s?output_format=md)–
   >’, esc_url( get_permalink() ), $time_string ) ); }

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Parse error: syntax error, unexpected T_STRING’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [cjohnson26](https://wordpress.org/support/users/cjohnson26/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_string-62/#post-5608287)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
