0

As far as I can see, I'm receiving 4 date fields from my mail server. date and/or Date - time when email were sent. MailDate and udate - time when email were received by my mail server.

Everything is clear with receiving time, since I have unix timestamp (udate).

The question is how to handle, how to convert in unix timestamp, sent time, since it could be in different formats. E.g. "Sat, 10 Mar 2015 11:26:43 +0100" and "Вто, 10 Декабря 2014 11:26:43 +0100 (12/10/2014 11:26:43 PM)" and "Lundi, 10 août 2014 11:26:43 +0800 (PST)" etc.

Is there any solution to reliably convert sent time in unix timestamp, or I should use it just as a string?

Garland Pope
  • 3,242
  • 1
  • 25
  • 19
beba
  • 82
  • 9

1 Answers1

0

Have you tried the intl extension for PHP? http://cz2.php.net/manual/en/intro.intl.php

Source: https://stackoverflow.com/a/11333780/722617

Community
  • 1
  • 1
Bryan Zwicker
  • 642
  • 1
  • 6
  • 24
  • Thank you Bryan. I suppose that intl extension suggested by you could resolve weekdays/months issue, and what to do with right part? To remove both braces and everything inside braces. Is it enough? If yes, then I can do what nickb suggested in http://stackoverflow.com/questions/11760924/convert-data-from-email-header – beba May 18 '15 at 18:05
  • I've never worked with it myself, but it seems to have its own versions of the strtotime() command, which would convert your timestamps to Unix timestamps, as you were looking for. Let us know if it gives you any success – Bryan Zwicker May 18 '15 at 18:07
  • If this answer helped you, please be sure to accept it! :) – Bryan Zwicker May 18 '15 at 19:47
  • Nope :( I already tried **nickb solution** a week ago, and it work with different formats w/o intl extension. I'm receiving proper timestamps from French, Russian and English formated dates. However, for some 25% of emails I'm receiving '0' instead of timerstamp. 93 emails in mailbox, 23 with '0' timestamp. 1 email from Yahoo user, one from a small local ISP user, and 21 generated with scripts (ISP support, Bank support, payoneer.com, onlinenic.com...). I suppose that a) I'm a moron, b) Errors in the scripts. But in my Evolution all emails are with dates. Is it proper date or just a string? – beba May 19 '15 at 13:06