php - Converting date to timestamp based on timezone -


i'm fetching emails using php imap , example of object:

array (     [0] => stdclass object         (             [subject] => email subject             [from] => sender <sender@domain.com>             [to] => me@domain.com             [date] => sat, 19 aug 2017 20:09:33 +1000             [message_id] => <80d657c74967c8dc56138ca9552f0a2e@anyweb.apca.local>             [size] => 1881518             [uid] => 703             [msgno] => 527             [recent] => 0             [flagged] => 0             [answered] => 0             [deleted] => 0             [seen] => 0             [draft] => 0             [udate] => 1503137430         )  ) 

although have udate wanted double check if matches timezone, did:

date_default_timezone_set('australia/melbourne'); $str = 'sat, 19 aug 2017 20:09:33 +1000'; echo strtotime($str); // 1503137373 ?? 

even tried:

$date = new datetime($str, new datetimezone('australia/melbourne')); $timestamp = $date->format('u'); echo $timestamp; // 1503137373 ??  

so in both cases timestamp doesn't match 1 thats fetched mail server, missing here?

  • udate - labeled mailserver

  • date, date - labeled client

the difference between 'date' , 'udate' seems rather more way they're formatted.

'date' date written in headers sender's mail client, , bears little reality. it's dependent on sender knowing correct time is; out few minutes, days, months or years.

'udate' real date e-mail hit imap server.

use 'udate' if want neat stuff work out how e-mail sent on daily basis - or, do, how spam get.

http://titanic.fauser.edu/php/function.imap-headerinfo.php.htm


from here:

date - message date found in headers

date - same date

udate - mail message date in unix time


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -