Solved

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

Posted on 2013-05-23
3
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 83

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 110

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySql Linux vs Windows: bad results for Windows but why? 10 63
Google Recaptcha 13 44
How can I send attachment with mail 5 20
Php variable to be sent back 3 28
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

736 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