Questions tagged [datetime-conversion]

Use this tag for questions related to the Datetime conversion, i.e. manipulating the Datetime in such a way, that a new, different in format, Datetime is produced.

is used in its general meaning, and is usually used for questions related on how to convert a Datetime object in another, new and with a different format, Datetime object, usually for making two different programming platforms communicate.

For example, your application may produce Datetimes of a specific format, but your Database to accept another Datetime format, different from the one your application is using. In that case, a conversion form the application's format to the Database's format is needed.

316 questions
11
votes
2 answers

What does division by 1e9d mean?

This is the snippet: String myTime = someTime / 1e9d + ","; someTime is derived by using System.nanoTime(). What does 1e9d do here?
user1071840
  • 3,522
  • 9
  • 48
  • 74
11
votes
8 answers

How to convert a 24 hour time to 12 hour in VB.net as hh:mm AM/PM

So let's say I have 1400, I want to convert it into 2:00PM I tried the following: Dim convertedTime As String = DateTime.ParseExact(theTime,"HHmm", Nothing) And it would give me this: 6/12/2012 02:00:00 PM I do not want the date part, neither do…
eastboundr
  • 1,857
  • 8
  • 28
  • 46
10
votes
10 answers

How to convert from UTC to local time in C?

It's a simple question, but the solution appears to be far from simple. I would like to know how to convert from UTC to local time. I am looking for a solution in C that's standard and more or less guaranteed to work on any computer at any…
aseq
  • 451
  • 1
  • 6
  • 23
10
votes
5 answers

Get Human readable time from nanoseconds

I am trying to implement an ETA feature Using System.nanoTime() startTime = System.nanoTime() Long elapsedTime = System.nanoTime() - startTime; Long allTimeForDownloading = (elapsedTime * allBytes / downloadedBytes); Long remainingTime =…
Sapnesh Naik
  • 11,011
  • 7
  • 63
  • 98
8
votes
4 answers

Storing dates and times in UTC and converting them local time in PHP/MySQL

I wanted to ask if this was going to work, before I went on a full fledged refactor of how i handle dates and times. To frame my question, here's my problem... I store "actions" taken by the user in a history table. These actions have a timestamp on…
jsheir
  • 111
  • 1
  • 5
8
votes
1 answer

Mapstruct LocalDateTime to Instant

I am new in Mapstruct. I have a model object which includes LocalDateTime type field. DTO includes Instant type field. I want to map LocalDateTime type field to Instant type field. I have TimeZone instance of incoming requests. Manually field…
7
votes
1 answer

Can we compare only time in mongodb?

I have stored happyHours of hotels in date time format. Now I want to fetch all hotels whose happyHours are greater than current time. As per my knowledge I know there is date comparison to fetch result but this will compare whole date time object.…
zulekha
  • 313
  • 9
  • 17
7
votes
2 answers

How to determine if the specific time is between given time range in javascript

i want to check var check_val in between two time var open_time and var close_time var open_time = "23:30"; var close_time = "06:30"; var check_val ="02:30"; if(Date.parse ( check_val ) > Date.parse ( open_time ) && Date.parse ( check_val ) <…
7
votes
4 answers

Converting DateTime to number of seconds in VB .NET

For converting number of seconds to DateTime, in VB .NET, I use the following code: Dim startDate As New DateTime(1970, 1, 1) Dim targetDate As DateTime Dim noOfSeconds As Integer = DataInSeconds targetDate =…
GVillani82
  • 17,196
  • 30
  • 105
  • 172
6
votes
3 answers

Calculating the difference between durations with milliseconds in Ruby

TL;DR: I need to get the difference between HH:MM:SS.ms and HH:MM:SS.ms as HH:MM:SS:ms What I need: Here's a tricky one. I'm trying to calculate the difference between two timestamps such as the following: In: 00:00:10.520 Out:…
slhck
  • 36,575
  • 28
  • 148
  • 201
6
votes
2 answers

How to convert java.time.format.TemoralAccessor to java.util.Date

How can I convert TemporalAccessor to java.util.Date? TemporalAccessor accessor = functionReturnsTemporalAccessor() Date date = Date.from(accessor) Date.from() does not accept TemporalAccessor, is there any way to convert to java.util.Date?
Dániel Kis
  • 2,341
  • 5
  • 28
  • 51
6
votes
3 answers

How can I convert a org.threeten.bp.OffsetDateTime to java.time.OffsetDateTime?

I'm using a client library (third party, not mine, cannot change) which utilizes the ThreeTen date types. My project is Java 11 and uses Java 8 date types. What is the recommended way to convert ThreeTeen objects to their Java 8 counterparts?
6
votes
1 answer

Unity c# convert date-string to datetime object in desired date time format

I need to convert a list of strings that contain date information (e.g. "2018-12-16") into DateTime format so that I can sort them all by date...and then convert back to string... I'm struggling to make this work. Testing on one of the…
Mike
  • 133
  • 1
  • 1
  • 8
6
votes
2 answers

Elixir add timezone data to naive date time

I have a NaiveDateTime that I need to add timezone data to. For example if I have a naive_date value like ~N[2015-10-03 12:00:00.000000] and I want set it to "America/Los_Angeles" timezone, how is that possible in Elixir?
Murcielago
  • 1,030
  • 1
  • 14
  • 24
6
votes
3 answers

Convert Unix/Linux time to Windows FILETIME

I am once again going from Windows to Linux, I have to port a function from Windows to Linux that calculates NTP time. Seems simple but the format is in Windows FILETIME format. I sort of have an idea what the differences are but so far I can not…
Dixon Steel
  • 1,021
  • 4
  • 12
  • 27
1
2
3
21 22