So I made a block of code using php to extract the latest tweet from twitter and this works but the date is shown as:
Fri Feb 21 09:24:06 +0000 2020
Is there a way to make this show as:
21 Feb 2020 9:24:06
I used the folowing block of code to load the data into a .txt file and I later retrieve all the data from this file:
$settings = array(
'oauth_access_token' => "**************",
'oauth_access_token_secret' => "**************",
'consumer_key' => "**************",
'consumer_secret' => "**************"
);
$url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
$requestMethod = "GET";
if (isset($_GET['user']))
{
$user = $_GET['user'];
}
else
{
$user = "User";
}
if (isset($_GET['count']))
{
$count = $_GET['count'];
}
else
{
$count = 1;
}
$getfield = "?screen_name=$user&count=$count&tweet_mode=extended";
$twitter = new TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(),$assoc = TRUE);
if(array_key_exists("errors", $string))
{
echo "<h3>Sorry, there was a problem.</h3><p>Twitter returned the following error message:</p><p><em>".$string[errors][0]["message"]."</em></p>";exit();
}
$fp = fopen('twitterData.txt', 'w');
foreach($string as $items)
{
$naam = $items['user']['name'];
$snaam = $items['user']['screen_name'];
$date = $items['created_at'];
$tekst = $items['full_text'];
$newTekst = str_replace(array("\n", "\r"), '', $tekst);
$Tweetstring = "<div class='Tweet'><div class='TweetUsername'><h2>". $naam."</h2></div><div class='TweetScreenname'><span>". $snaam."</span><br><span>".$date."</span></div><div class='TweetTxt'>". $newTekst."</div></div></a>";
fwrite($fp, 'let Tweet = "'.$Tweetstring.'";');
}
fclose($fp);
I just hope someone has the answer for me and it doesn't have to be specifically PHP it can also be javascript or jQuery.