There are multiple ways of achieving what you want using CSS, however all of them require you to at least wrap the "left" or "right" part in it's own container.
One option (as suggested by others) for this would be to use float like this:
PHP:
<time style="width:194px;" datetime="<?php echo esc_attr(date_format($ts, 'H:i d-m-Y')) ?>"data-timezone="<?php echo esc_attr($tz_param) ?>">
<?php echo ucfirst(date_i18n('j F', $ts->getTimeStamp()-(60*60*4))); ?>
<span><?php echo date_i18n('H:i', $ts->getTimeStamp()-(60*60*4))); ?></span>
</time>
CSS:
time > span {
float: right;
}
If you would want to be clean, you should probably clear the float afterwards.
You could also use two <span>
elements, one for the date and one for the time and then use display: flex;
(to understand Flexbox, I'd recommend reading this article: https://css-tricks.com/snippets/css/a-guide-to-flexbox/) like this:
PHP:
<time style="width:194px;" datetime="<?php echo esc_attr(date_format($ts, 'H:i d-m-Y')) ?>"data-timezone="<?php echo esc_attr($tz_param) ?>">
<span><?php echo ucfirst(date_i18n('j F', $ts->getTimeStamp()-(60*60*4))); ?></span>
<span class="time-right"><?php echo date_i18n('H:i', $ts->getTimeStamp()-(60*60*4))); ?></span>
</time>
CSS: (Either use Option 1 or Option 2, not both)
/* OPTION 1 */
time {
display: flex;
}
time > span {
flex-grow: 1;
}
time > span.time-right {
text-align: right;
}
/* OPTION 2 */
time {
display: flex;
justify-content: space-between;
}
/* Note: There are many more options achieving this using flex */
You could also use relative and absolute positioning for this, by giving the <time>
element a position: relative
and the <span>
a position: absolute; right: 0;
<time datetime="00:15 02-08-2019" style="width:194px;" data-timezone="et">August 2 00:15</time>
– Archuleta'j F &\nb\sp; &\nb\sp; H:i'
inucfirst(date_i18n( 'j F &\nb\sp; &\nb\sp; H:i', $ts->getTimeStamp()-(14400)));
is your format string. It is essentially a template.<span>j F</span><span>H:i</span>'
, but you may need to escape the<span></span>
parts. I don't know php well enough to tell you how to go about doing that. – Tiller<span>
's you could use:display: flex; justify-content: space-between;
on their parent. – Wendelina