?
Solved

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

Posted on 2013-05-23
3
Medium Priority
?
268 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 84

Accepted Solution

by:
Dave Baldwin earned 1000 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we’ll look at how to deploy ProxySQL.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …
Suggested Courses
Course of the Month16 days, 12 hours left to enroll

862 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