timestamp

If I have a PHP string in the format YYYY-DD-MM and a timestamp in MySQL, is there a good way to convert between them?

I'm interested in doing comparisons between the date string and the MySQL timestamp. However, I'm not seeing an easy conversion. Am I overlooking something obvious? ...

SQL Server 2005 Auto Updated DateTime Column - LastUpdated

I have a table defined (see code snippet below). How can I add a constraint or whatever so that the LastUpdate column is automatically updated anytime the row is changed? CREATE TABLE dbo.Profiles ( UserName varchar(100) NOT NULL, LastUpdate datetime ...

Java: Date.getTime() not including time?

Can't understand why the following takes place: String date = "06-04-2007 07:05"; SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm"); Date myDate = fmt.parse(date); System.out.println(myDate); //Mon Jun 04 07:05:00 EDT 2007 long timestamp = myDate.getTime(); System.out.println(timestamp); //1180955100000 -- where are the...

How do I convert between time formats?

I am looking to convert a mysql timestamp to a epoch time in seconds using php, and vice versa. What's the cleanest way to do this? ...

Convert mysql timestamp to epoch time in python

Convert mysql timestamp to epoch time in python - is there an easy way to do this? ...

How do you avoid adding timestamp fields to your tables?

I have a question regarding the two additional columns (timeCreated, timeLastUpdated) for each record that we see in many solutions. My question: Is there a better alternative? Scenario: You have a huge DB (in terms of tables, not records), and then the customer comes and asks you to add "timestamping" to 80% of your tables. I believe ...

mysql timestamp column

Hi, Is it possible to define a timestamp column in a MySQL table that will automatically be updated every time a field in the same row is modified? Ideally this column should initially be set to the time a row was inserted. Cheers, Don ...

Accurate timestamping in Python

I've been building an error logging app recently and was after a way of accurately timestamping the incoming data. When I say accurately I mean each timestamp should be accurate relative to each other (no need to sync to an atomic clock or anything like that). I've been using datetime.now() as a first stab, but this isn't perfect: >>> ...

Are unix timestamps the best way to store timestamps?

I always use unix timestamps for everything, but am wondering if there is a better way. What do you use to store timestamps and why? ...

How do you convert VARCHAR to TIMESTAMP in MSSQL?

You'd like to call a stored proc on MS SQL that has a parameter type of TIMESTAMP within T-SQL, not ADO.NET using a VARCHAR value (e.g. '0x0000000002C490C8'). What do you do? UPDATE: This is where you have a "Timestamp" value coming at you but exists only as VARCHAR. (Think OUTPUT variable on another stored proc, but it's fixed alread...

How do you get a timestamp in JavaScript?

Something similar to Unix's timestamp, that is a single number that represents the current time and date. Either as a number or a string. ...

Creation timestamp and last update timestamp with Hibernate and MySQL

For a certain Hibernate entity we have a requirement to store its creation time and the last time it was updated. How would you design this? What data types would you use in the database (assuming MySQL, possibly in a different timezone that the JVM)? Will the data types be timezone-aware? What data types would you use in Java (Date,...

Java Timestamp valueOf

I came across a code snippet like this: Timestamp expiryDate = Timestamp.valueOf(dateStr + " " + "23:59:59.000"); Here dateStr is a string entered by the user in a form, in the format yyyy-mm-dd. Now the behavior of Timestamp.valueOf is such that it converts non-existent dates into appropriate proper dates. Say 31st June 2008 into 01s...

Resetting the time part of a timestamp in Java

In Java, given a timestamp, how to reset the time part alone to 00:00:00 so that the timestamp represents the midnight of that particular day ? In T-SQL, this query will do to achieve the same, but I don't know how to do this in Java. SELECT CAST( FLOOR( CAST(GETDATE() AS FLOAT ) ) AS DATETIME) AS 'DateTimeAtMidnight'; ...

Getting Precise Times in PHP

I have noticed that regardless of a given script's execution time, every date() call will return the same timestamp regardless of where the function is called within the script. It looks like it just returns the time at which the script first started executing. For logging purposes, it would be extremely useful to be able to get increme...

SQL - Table Design - DateCreated and DateUpdated columns

For my application there are several entity classes, User, Customer, Post, and so on I'm about to design the database and I want to store the date when the entities were created and updated. This is where it gets tricky. Sure one option is to add created_timestamp and update_timestamp columns for each of the entity tables but that isn't...

What is the simplest way to format a timestamp from sql in php?

What is the simplest, fastest way to complete the PHP code below such that the output is in a user-friendly format (e.g."October 27, 2006")? $result = mysql_query("SELECT my_timestamp FROM some_table WHERE id=42", $DB_CONN); $row = mysql_fetch_array($result); $formatted_date = ???($row['my_timestamp']); echo $formatted_date; ...

How to convert UNIX timestamp to DateTime and vice versa?

As the title says really. There is this example code, but then it starts talking about millisecond / nanosecond problems. http://blogs.msdn.com/brada/archive/2004/03/20/93332.aspx Edit: This is what I've got so far: public Double CreatedEpoch { get { DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLoca...

Rename a file with a batch script

How do you rename a file to include the datetime using the windows command line? ...

How can I insert current date and time into a file using Emacs?

What commands in Emacs can I use to insert into the text buffer of a file the current date and time? (For example, the equivalent in Notepad is simply pressing F5 which is about the only useful feature for Notepad!) ...