Jump to content

IMAP date


dreni

Recommended Posts

The imap code below displays the date like this:

Sat, 18 Feb 2012 19:22:02 +0100

I want the date to be displayed like this instead:

2012-02-18

 

Any idea how I can achieve this?

 

Thanks in advance

 

<?php
date_default_timezone_set ("Europe/Stockholm");
/* connect to mail */
$hostname = '{xxx.xxxx.com:143/notls}INBOX';
$username = 'xxxxx@xxxxx.com';
$password = 'xxxxxx';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Anslutning till mail misslyckades: ' . imap_last_error());

/* grab emails */
$emails = imap_search($inbox,'ALL');

/* if emails are returned, cycle through each... */
if($emails) {
  
  /* begin output var */
  $output = '';
  
  /* put the newest emails on top */
  rsort($emails);
  
  /* for every email... */
  foreach($emails as $email_number) {
    
    /* get information specific to this email */
    $overview = imap_fetch_overview($inbox,$email_number,0);
    $message = imap_fetchbody($inbox,$email_number,2);
$date = date('d m Y');
    $swedate = $overview[0]->date;
    /* output the email  information */
    $output.= '<li>';
$output.= '<a href="#"><strong>'.$swedate.'</strong> ';
    $output.= ''.$overview[0]->subject.'<br> ';
    $output.= '<small> Från: '.$overview[0]->from.'</small></a>';
    $output.= '</li>';
    

  }
  
  echo $output;
  
} 

/* close the connection */
imap_close($inbox);


?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.