How can I get millisecond and microsecond-resolution timestamps in Python?

For Windows: Here’s a fully-functional module for both Linux (works with pre-Python 3.3 too) and Windows: Functions and code samples. Functions include: micros() millis() delay() delayMicroseconds() Python code module (on GitHub as eRCaGuy_PyTime): “”” GS_timing.py -create some low-level Arduino-like millis() (milliseconds) and micros() (microseconds) timing functions for Python By Gabriel Staples http://www.ElectricRCAircraftGuy.com -click “Contact me” … Read more

How do you specify the date format used when JAXB marshals xsd:dateTime?

You can use an XmlAdapter to customize how a date type is written to XML. package com.example; import java.text.SimpleDateFormat; import java.util.Date; import javax.xml.bind.annotation.adapters.XmlAdapter; public class DateAdapter extends XmlAdapter<String, Date> { private final SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”); @Override public String marshal(Date v) throws Exception { synchronized (dateFormat) { return dateFormat.format(v); } } @Override public … Read more

Timestamp with a millisecond precision: How to save them in MySQL

You need to be at MySQL version 5.6.4 or later to declare columns with fractional-second time datatypes. Not sure you have the right version? Try SELECT NOW(3). If you get an error, you don’t have the right version. For example, DATETIME(3) will give you millisecond resolution in your timestamps, and TIMESTAMP(6) will give you microsecond … Read more

How to get milliseconds from LocalDateTime in Java 8

I’m not entirely sure what you mean by “current milliseconds” but I’ll assume it’s the number of milliseconds since the “epoch,” namely midnight, January 1, 1970 UTC. If you want to find the number of milliseconds since the epoch right now, then use System.currentTimeMillis() as Anubian Noob has pointed out. If so, there’s no reason … Read more

Getting date format m-d-Y H:i:s.u from milliseconds

You can readily do this this with the input format U.u. $now = DateTime::createFromFormat(‘U.u’, microtime(true)); echo $now->format(“m-d-Y H:i:s.u”); This produces the following output: 04-13-2015 05:56:22.082300 From the PHP manual page for date formats: U = Seconds since the Unix Epoch u = Microseconds http://php.net/manual/en/function.date.php Thanks goes to giggsey for pointing out a flaw in my … Read more