469,299 Members | 2,079 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

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 4811
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ben | last post: by
reply views Thread by Andy Jackman | last post: by
reply views Thread by krystoffff | last post: by
reply views Thread by alt | last post: by
4 posts views Thread by Ross Contino | last post: by
5 posts views Thread by Sturnoff Megantic | last post: by
7 posts views Thread by up2trouble | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.