1

how would I echo out the $dateSpan1 and $dataSpan2 variable for HTML?

php code:

$dateSpan1 = '<span class=bydatepad>';
$dateSpan2 = '</span>';
$variables['date'] = format_date($variables['node']->created, 'custom', ($dateSpan1 . 'F j, Y' . $dateSpan2 . $dateSpan1 . 'g:i a' . $dateSpan2));
$variables['submitted'] = t('By: ' . ' !username ' . ' !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date']));

current results:

<00pam6 2015-06-15T10:05:00-04:00Mondayam0000=b1515am30America/New_Yorkpam15>June 15, 2015 <00pam6>
<00pam6 2015-06-15T10:05:00-04:00Mondayam0000=b1515am30America/New_Yorkpam15> 10:05 am<00pam6>

results I want:

Display: June 15, 2015 10:05 am 
HTML: <span class=bydatepad>June 15, 2015</span><span class=bydatepad>10:05 am</span>

3 Answers 3

4

You should format your date without any html markup, and then add your markup. And by the way add double quotes to html attribs.

$variables['date'] = '<span class="bydatepad">'.format_date(...).'</span>';
Sign up to request clarification or add additional context in comments.

Comments

1

you can do this with fixed escape chars

$dateSpan1 = '\<span class=bydatepad\>';
$dateSpan2 = '\<\/span\>';

or you can make a function that does it for you.

Comments

1
echo htmlspecialchars($dateSpan1);

That should do it, just change the variable inside the function depending on what you want to display at that time

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.