How can I find the amount of seconds passed from the midnight with Java?

If you’re using Java >= 8, this is easily done : ZonedDateTime nowZoned = ZonedDateTime.now(); Instant midnight = nowZoned.toLocalDate().atStartOfDay(nowZoned.getZone()).toInstant(); Duration duration = Duration.between(midnight, Instant.now()); long seconds = duration.getSeconds(); If you’re using Java 7 or less, you have to get the date from midnight via Calendar, and then substract. Calendar c = Calendar.getInstance(); long now = … Read more

Sort directory files by creation datetime in Windows filesystem

On windows the CTime is the creation time, use the following: <?php $files = array(); foreach (new DirectoryIterator(‘/path’) as $fileInfo) { $files[$fileInfo->getFileName()] = $fileInfo->getCTime(); } arsort($files); After this $files will contain an array of your filenames as the keys and the ctime as the values. I chose this backwards representation due to the possibility of … Read more

Does anyone know of a good JSON time server?

As of Jan. 07th 2020 http://worldtimeapi.org/ is working fine. we can get current date and time details for specfic time-zone or ip address easily in either json format or plain text format. http://worldtimeapi.org/api/timezone/America/Santiago the above url will give you the current date and time details in json for “America/Santiago”. http://worldtimeapi.org/api/timezone/Asia/Kolkata the above url will give … Read more

JavaScript NTP time

First of all, the JS scheduler has a certain granularity – that is, you can request an interval smaller than, say, 20 msec, but it will not fire immediately – what you could see is 20 events fired off every 20 msec. Second, even if you could, this is not a good idea: you would … Read more

How can I get the date & time from the network provider?

You may need to use a custom NITZ or NTP Library http://groups.google.com/group/android-developers/browse_thread/thread/d5ce3bcfe17e272b?pli=1 So just a heads up that Android uses NITZ events provided by a carrier to properly set the system date and time. Android also falls-back to network NTP automatically when no cellular network is available. http://en.wikipedia.org/wiki/NITZ The time provided by currentTimeMillis() will typically … Read more