473,385 Members | 1,582 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,385 software developers and data experts.

Convert to Unix Timestamp

Hello

How can I convert a date into the Unix timestamp?

I don't really mind what format the date is in, something like MMDDYY
would be fine, can someone show me what code I would need to do that
please/

Thanks.

There's plenty of functions out there to convert FROM a Unix timestamp
but I can't find any for the other way round.
Feb 7 '08 #1
4 11394
It's OK I worked it out using the mktime function, sorry to bother
you.

Here's the code in case anyone else is as dumb as me ;-)

$aDate = explode("/",$date);

$unixtime = mktime(0, 0, 0, $aDate[1], $aDate[0], $aDate[2]);

(This will take the $date in format DD/MM/YY)
Feb 7 '08 #2
shorter:

strtotime($date);
Feb 7 '08 #3
jpedrobarbosa wrote:
strtotime($date);
Though that behaves unreliably with dd/mm/(yy)yy dates.
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 9 days, 15:56.]

The Great IE8 Meta Tag Debacle
http://tobyinkster.co.uk/blog/2008/02/06/ie-8-meta-tag/
Feb 8 '08 #4
didnt know that: thanks ;-)
Feb 8 '08 #5

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

Similar topics

2
by: | last post by:
First of all, I want to know if Cookie's expiration time and HTTP's header's last modified time are using the same format. Secondly, how do I format the time from a 10923023324324 kind of number...
13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
1
by: Sugapablo | last post by:
How do you convert a unix timestamp to date('Y-m-d H:i:s')?
3
by: Ralf Meuser | last post by:
Hi there, I get form a database time with the format : 'Jan 01 1900 06:00PM' I want to convert it to :HH:MM I tryed it with $heure=(date("H:i",strtotime($row)) but I get allways 20:55. even...
3
by: Bruno BAGUETTE | last post by:
Hello, I'm looking for a way to convert a unix timestamp to a PostgreSQL date without using ::abstime which seems to be deprecated. Currently, I do that query : levure=> select...
2
by: Luis P. Mendes | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I've inserted a couple hundred rows in a table in Postgres via psycopg2. The first field of each row is a certain unix time (since epoch)...
6
by: marc | last post by:
hi im trying to convert Date() into a unix timestamp so i can stick the result into a mysql db, please help!
3
by: SpreadTooThin | last post by:
I am wondering if someone who knows the implemention of python's time could help converting this to c/c++.... nanoseconds = int(time.time() * 1e9) # 0x01b21dd213814000 is the number of 100-ns...
3
by: Jonathan | last post by:
I have taken up C++ programming again and need to write a socket client, so far I am able to create the connection to the socket. As I need a unix timestamp in char to put on a socket in a HTTP...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.