473,378 Members | 1,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

unix_timestamp

Why does this return 0 ?

SELECT UNIX_TIMESTAMP('20051001');

It should be the unix timestamp of that date.
Oct 18 '05 #1
5 4920
meltedown wrote:
Why does this return 0 ?

SELECT UNIX_TIMESTAMP('20051001');

It should be the unix timestamp of that date.


That would suggest you are using local time, if there a locale set on
mysql and also another thing to check, is the date set :)

This is what I get:
mysql> SELECT UNIX_TIMESTAMP('20051001');
+----------------------------+
| UNIX_TIMESTAMP('20051001') |
+----------------------------+
| 1128142800 |
+----------------------------+
1 row in set (0.01 sec)

--
Mike Willbanks
Zend Certified Engineer
http://www.digitalstruct.com
Oct 18 '05 #2
Mike Willbanks wrote:
meltedown wrote:
Why does this return 0 ?

SELECT UNIX_TIMESTAMP('20051001');

It should be the unix timestamp of that date.

That would suggest you are using local time, if there a locale set on
mysql and also another thing to check, is the date set :)

This is what I get:
mysql> SELECT UNIX_TIMESTAMP('20051001');
+----------------------------+
| UNIX_TIMESTAMP('20051001') |
+----------------------------+
| 1128142800 |
+----------------------------+
1 row in set (0.01 sec)

I don't get it. I don't know what "using local time" means;
I think I'm going about it all wrong anyway.
I'm trying to find the first and last day of the month of this datetime:
2005-10-17 19:10:11
Oct 18 '05 #3
>>
This is what I get:
mysql> SELECT UNIX_TIMESTAMP('20051001');
+----------------------------+
| UNIX_TIMESTAMP('20051001') |
+----------------------------+
| 1128142800 |
+----------------------------+
1 row in set (0.01 sec)

I don't get it. I don't know what "using local time" means;
I think I'm going about it all wrong anyway.
I'm trying to find the first and last day of the month of this datetime:
2005-10-17 19:10:11


The local time is specified by server time. If your server time is not
set or not enabled mysql can not really give you timestamps. However,
for what you are doing you could use the mysql function last_day(date)
if you are using 4.1.1 or greater for the last day :)

You should look into your server setup to see what is actually going on
when you are running that query. I ran mine from the shell using the
mysql client.

Mike

--
Mike Willbanks
Zend Certified Engineer
http://www.digitalstruct.com
Oct 18 '05 #4
Mike Willbanks wrote:

This is what I get:
mysql> SELECT UNIX_TIMESTAMP('20051001');
+----------------------------+
| UNIX_TIMESTAMP('20051001') |
+----------------------------+
| 1128142800 |
+----------------------------+
1 row in set (0.01 sec)

I don't get it. I don't know what "using local time" means;
I think I'm going about it all wrong anyway.
I'm trying to find the first and last day of the month of this datetime:
2005-10-17 19:10:11

The local time is specified by server time. If your server time is not
set or not enabled mysql can not really give you timestamps. However,
for what you are doing you could use the mysql function last_day(date)
if you are using 4.1.1 or greater for the last day :)

You should look into your server setup to see what is actually going on
when you are running that query. I ran mine from the shell using the
mysql client.

Mike

I get timestamps all the time, so I don't see how that is the problem.
this seems to work:SELECT UNIX_TIMESTAMP('2005-10-01');
All I did was add the dashes

Oct 18 '05 #5
> I get timestamps all the time, so I don't see how that is the problem.
this seems to work:SELECT UNIX_TIMESTAMP('2005-10-01');
All I did was add the dashes


Interesting, what version of MySQL are you running? That could be the
issue.
--
Mike Willbanks
Zend Certified Engineer
http://www.digitalstruct.com
Oct 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ben | last post by:
I would like to use php to query a database and retrieve a unix timestamp. The problem is that mysql is storing the data in the date format and not a timestamp. I am sure that I can amend my...
0
by: Andy Jackman | last post by:
Hi, 1) I was investigating the unix_timestamp routine in mysql (version 3.23.46-nt) and for some reason the unix epoch (1-1-1970) was returned with a value of -3600. Then, as you can see, it...
0
by: krystoffff | last post by:
Hi all I wrote a script in PHP with MySQL 4.1 (so in this version, subqueries are allowed) but this is a very very long script ... I was wondering if there is a way to optimize this one, by...
0
by: alt | last post by:
UNIX_TIMESTAMP() UNIX_TIMESTAMP(date) If called with no argument, returns a Unix timestamp (seconds since '1970-01-01 00:00:00' GMT) as an unsigned integer. If UNIX_TIMESTAMP() is called with a...
4
by: Ross Contino | last post by:
Hello to all: I have been searching the web for examples on how to determine a median value in a mySQL table. I have reviewed the article at...
5
by: Sturnoff Megantic | last post by:
I have columns called repeat_date and repeat_month and I would like to use the info within them in my WHERE clause as part of a UNIX_TIMESTAMP(). Essentially, I would like to say something like:...
2
by: mattdfong | last post by:
I am using mysql to receive stock market rate data, and I have a rate feed which tells me when the rate has changed. I input the data as it comes in, into a mysql database that has both a...
3
by: planetthoughtful | last post by:
Hi All, I'm trying to determine the number of days between today and the value in a datetime field in a table. It appears my version of MySQL doesn't have DATEDIFF available, so I'm wondering...
7
by: up2trouble | last post by:
In mysql, I have a field defined as a time stamp. It is storing value as 0000-00-00 00:00:00. It to store it in seconds. <?PHP $entered = mktime(); echo "<INPUT TYPE='text' NAME='$entered'...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.