Solved

email is 5 hours behind, sms 0 hours behind: how to sort

Posted on 2013-05-23
3
253 Views
Last Modified: 2013-05-26
I downloaded gmails and noticed the email time is 5 hours behind
my sms are in real time 0 hours behind


CREATE TABLE `email_doc` (
  `id` int(11) NOT NULL auto_increment,
  `unix_timestamp` bigint(20) default NULL,
  `from_email` varchar(200) default NULL,
  `from_name` varchar(200) default NULL,
  `to_email` varchar(200) default NULL,
  `to_name` varchar(200) default NULL,
  `subject` varchar(400) default NULL,
  `body` varchar(4000) default NULL,
  `real_id` varchar(30) default NULL,
  `checked` int(11) default NULL,
  `me_description` varchar(9000) default NULL,
  `client_description` varchar(4000) default NULL,
  `sms_type` tinyint(4) default NULL,
  `client_start` datetime default NULL,
  `client_end` datetime default NULL,
  `client_total` int(11) default NULL,
  `me_start` datetime default NULL,
  `me_end` datetime default NULL,
  `me_total` int(11) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `unix_timestamp` (`unix_timestamp`)
) ENGINE=MyISAM AUTO_INCREMENT=1758 DEFAULT CHARSET=utf8$$




select * from email_doc order by unix_timestamp

if email (real_id is not null), then the time is unix_timestamp +5 hours


$row->unix_timestamp+18000

is sms
real_id is null
$row->unix_timestamp


when I use php I see messages out of order

echo $row->unix_timestamp;
if (!empty($row->real_id)){
echo'<br>'.date("M j, g:i A", $row->unix_timestamp+18000);  
echo '<br>'.$row->subject;
}else{
  echo'<br>'.date("M j, g:i A", $row->unix_timestamp);
}

Open in new window



I want to order by time, not unix_timestamp



I think it would be best if I can sort using mysql query
0
Comment
Question by:rgb192
3 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 39193513
'unix_timestamp' is the date and time in seconds since Jan 1, 1970.  While you can format it or convert it to be 'human readable', it is time.  And since it is a single number, it sorts very well.  Other formats probably convert to unix_timestamp for most operations.
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 39194991
Please read this article, where all of this sort of thing is explained -- either in the text or in the linked man page references and articles.  If you find it TLDR, take a break and then come back to it.  If you're going to write computer programming that is sensitive to DATETIME values you need to understand this stuff!
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

See especially: http://php.net/manual/en/function.date-default-timezone-set.php
0
 

Author Closing Comment

by:rgb192
ID: 39198445
based upon your suggestions I created another unix_timestamp column

thanks
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now