0
$query = new WP_Query($args);
while ($query -> have_posts()) : $query -> the_post(); ?>
<tr>
<td><?php the_field('home_player'); ?></td>
<td><?php displayresult(the_field('result')); ?></td>
<td><?php the_field('away_player'); ?></td>
<td><?php date('dS F Y', the_field('date')); ?></td>
<td><?php the_field('board'); ?></td>
</tr>
<?php endwhile; ?>
這是我正在處理的代碼。我將日期存儲爲時間戳,我試圖在php中使用日期函數進行轉換。正如寫這篇文章,它發生在我身上,它可能是一個字符串,而不是數字。我測試了它,結果the_field只返回字符串。有什麼辦法將它轉換爲數字嗎?Wordpress the_field();轉換爲數字
之前有人問我試過「the_field('date')+ 0」 –
通過時間戳你的意思是一個unix時間戳,一個數值例如'1453577004',只有你有它的字符串形式,''1453577004'' ?你不需要將它轉換爲數字以將它作爲第二個參數傳遞給'date'函數 - PHP的自動類型轉換將處理該數據。 – CBroe
你的意思是[strtotime](http://php.net/manual/en/function.strtotime.php)? –