Most voted "datetime" questions
A Datetime object in many programming languages describes a date and an hour of the day. It can express either an instant in time or a position on a calendar, depending on the context in which it is used and the specific application. This tag can be used for any question related to date and time.
Learn more…440 questions
Sort by count of
-
37
votes5
answers409
viewsToday (06/30/2015) we will have a second more, what could be the consequences for our systems?
In case anyone doesn’t know, today 30/06/2015 We’ll have an extra second. That is, today after the 23h59m59s we shall have 23h59m60s! This to make the correction of International Atomic Time. I know…
-
33
votes7
answers10590
viewsHow do I know if today’s date is Saturday or Sunday (weekend) in PHP?
I want to know the simplest possible way to find out if today’s date is Saturday or Sunday in PHP. What are the possible ways to do this?
-
28
votes2
answers3404
viewsHow do I migrate from Date and Calendar to the new Java 8 Date API?
Until Java 7, we had the classes Date and Calendar to represent dates. To convert them to Strings, the easiest way was with the use of SimpleDateFormat. Java 8 has introduced a new date API. How can…
-
23
votes6
answers28585
viewsHow to get Timestamp in Javascript?
I’d like to know how I do in JavaScript to obtain the Timestamp? A number that represents the current date and time. I know we got the object for date and time through: var d = new Date(); But I…
-
22
votes2
answers574
viewsIs it possible to have month 13 on a date in Java?
I was looking at the class documentation Formatter java 7, this link from Oracle itself, when I noticed myself with the following example below: What intrigued me was the example given for the month…
-
19
votes3
answers2369
viewsDefinition of the day of the week in the Gregoriancalendar
I have the following code which is responsible for creating a Gregoriancalendar for handling a date. TimeZone tz = TimeZone.getTimeZone("America/Sao_Paulo"); TimeZone.setDefault(tz); Calendar…
-
16
votes3
answers40219
viewsHow to format a date in 'dd/MM/yyyy' format?
How to get a formatted string from an object of type Date in format dd/MM/yyyy?
-
15
votes4
answers805
viewsHow to use Simpledateformat in concurrent environments?
The class SimpleDateFormat is not thread safe. I recently had problems with class instances SimpleDateFormat in static context being used by multiple threads concurrently in a web application.…
-
14
votes3
answers13485
viewsChange the Datetime Timezone.
I am hosting my system on a server that is in the USA. So when using the DateTime.Now returns the date and time of the US. I would like you to return the date and time of Brazil. It is possible?…
-
14
votes4
answers2074
viewsHow to get the format in hours when it exceeds 24?
I’m developing a PHP system where I need to get the total time of an audio file at some point. This time is saved in the database in seconds and also in the format of hours. The problem is that when…
-
12
votes3
answers1357
viewsRetrieve date and local time of an arbitrary day in an arbitrary Timezone, considering daylight saving time
I want to show the day, hour, minute etc. in an arbitrary Timezone, in an arbitrary day. How to talk about timezone conversion is always difficult and confusing, and how to talk about timezone…
-
12
votes2
answers7696
viewsGet the current date and time by internet in desktop application
I am implementing a system lock by date, and I need to get the current date of Brasilia for example, which would be the official time of Brazil, or the date in time zone -3. I believe that there are…
-
12
votes3
answers7644
viewsHow to create a Datetime object that represents the last day of a given month?
On an object of the type DateTime, how do I get a new object object DateTime representing the last day of the month of the first object? var data = new Date(2017, 3, 1); // 01/03/2017 var…
-
12
votes5
answers5490
viewsCount the number of months between one date and another
I would like your help to basically count the amount of months between a date and another. I’ll give you an example but what I want is basically just an accountant. Ex: quantity of months between…
-
12
votes1
answer1140
viewsWhy should I use Joda-Time or not?
The question comes mainly based on comment from one of our most active users today and who has already demonstrated extraordinary knowledge in time use, especially in Java. the java.time API would…
-
11
votes5
answers2480
viewsCheck if day exists in month
I need to verify/validate if a (numerical) day exists in a given month. For example, I have the day 31, and as it does not exist in the month of February the condition will fail. I think a simple if…
-
11
votes5
answers64148
viewsDifference between two dates in days, hours, minutes and seconds
Problem: How to subtract between two dates and return the value in Days, Hours, Minutes and Seconds in an SQL query with SQL Server 2014? Example: Dados: DataRecebimento DataEnvio 2013-11-29…
-
11
votes4
answers16866
viewsHow to know which DATETIME format is used in a given column of SQL Server?
I have a table on SQL Server and one of the camps was created as DATETIME. How should I know query or SQL Server Studio, what format default used of this DATETIME in my SQL Server?…
-
10
votes3
answers471
viewsAdd custom timezones in PHP?
TL;DR Is there any way to add timezones customized in PHP? Goal I would like to be able to register a schedule (using new DateTime(...)) with an arbitrary time offset value (Timezone), for example…
-
10
votes6
answers14461
viewsConvert month number to name
I need to convert the number of the month to the name of the same, but it has to be in Portuguese (and preferably without the need to substr) I can do this with the standard English language…
-
10
votes3
answers1283
viewsRemove Saturdays and Sundays from Calculation
I have a project where I work with activities of a project, my activities have a certain time to be completed, but the project has to make the calculation only with administrative days. For example…
-
10
votes2
answers49607
viewsHow to format a Datetime field in Brazilian dd/MM/yyyy format?
I would like to format the fields DataAfr and DataTrm of the kind DATETIME, in the Brazilian date format dd/MM/YYYY instead of the American format yyyy-mm-dd hh:mm:ss SELECT e.NmrCnt AS [Contrato]…
-
10
votes4
answers271
viewsJavascript equivalent of "Date.now()" in C#?
Here speaks how to get milliseconds using Date.now();, that returns something like 1533144170651. Follows his documentation: The method now() returns the milliseconds since January 1 1970 00:00:00…
-
9
votes4
answers7984
viewsHow to solve 3-hour accretion problem in Date attribute in Angular?
I have the following excerpt: let data = new Date(); console.log(data); // saída: Fri Oct 18 2019 08:23:27 GMT-0300 (Horário Padrão de Brasília) When making the request with the HttpClient Angular…
-
8
votes6
answers8101
viewsHow to take the current date and add "n" minutes in this value?
I can get the current date simply with new Date(), but how do I add an amount of minutes to this value? If there is a way to add milliseconds, it may also be.
-
8
votes3
answers15165
viewsHow to subtract two dates using Python?
How do I know the difference in days between two dates using Python? For example; How to know how many days there are between 22/11/2013 and 25/03/2014, considering a possible leap year.…
-
8
votes1
answer696
viewsError trying to convert Portuguese date into datetime
I’m in trouble and I’m not finding any solution to fix it. I have a date in this format: Wednesday, 30 April, 2014 and I want to save this date in the database on type datetime. So I’m trying to…
-
8
votes3
answers1220
viewsGet timestamp
I have two variables, one with the date and the other with the time. How can I get your timestamp of the two variables. Example: var data = 02/01/2015; var hora = 10:00:00; var d = new Date(data +…
-
8
votes2
answers1332
viewsConvert string to Datetime in LINQ
I have a model where all fields are string. I want to convert to DateTime and Double For that I created a new model public class CPUStats { public DateTime Data { get; set; } public Double? Disco {…
-
8
votes5
answers14934
viewsSort Datatable Datetime Field
Hello. I have the following datatable: success: function (data) { $('#table-controle').html(data); $('#table-controle').DataTable({ "language": { "url":…
-
8
votes3
answers182
viewsConvert date type 2016-10-04 15:51:16 to, 04-10-2016 15:51:16 to SQL or PHP how to do?
I’m doing a job to show the date and time of insertion in the script in the database, I have to show the date in the dd-mm-yyyyyy format and then the time, can I do it by the script’s SELECT or by…
-
8
votes5
answers833
viewsHow to calculate the date and shift code?
I have a table that specifies the starting time of a work shift and its duration in minutes: codigo descricao inicio(datetime) duracao(int) S01 PRIMEIRO 1900-01-01 05:00:00.000 540 S02 SEGUNDO…
-
8
votes1
answer4854
viewsConvert a str to datetime in Python
I am creating a task manager that should receive a task with a deadline. This manager will check how many days left to the deadline and let you know when to arrive. However, I am having a problem…
-
7
votes3
answers3924
viewsHow to know the week of a given month?
I am working on ASP.NET MVC 4, and I intend to know what is the week of a given month. For example, the user wants to set a frequency of occurrences, and as such says: The occurrence will happen…
-
7
votes3
answers6519
viewsHow to get a difference between two dates?
Let’s just say I have an initial date equal to 30/01/2014 10:00 and a final date equal to 02/02/2014 10:00. I would like to know if it is possible to obtain a grid containing these results: If…
-
7
votes4
answers1804
viewsShould I check dates with Datetime or regex?
I have seen two different ways to check whether a date is valid. In a "modern" way, with DateTime: $date="2014-02-04"; $dt = DateTime::createFromFormat("Y-m-d", $date); return $dt !== false…
-
7
votes6
answers5869
viewsHow to know the number of a week in each month
I am working on ASP MVC4, and would like to know the number of weeks in a given month to generate a list of dates. For example, the user inserts a week, and in that week of each month I will…
-
7
votes2
answers4567
viewsHow to turn a string into Date format in R?
In the code below the dates are in the format: Mes Dia Ano. I need R to recognize the variable as date. #importa os dados library(XML)…
-
7
votes4
answers10421
viewsHow can I get a date (day, month, year, time, minute, and second) converted into milliseconds in Java?
How can I get a date in milliseconds? Example: 24, Sat, Jan, 17:39:50 2015
-
7
votes2
answers3134
viewscalculate difference between two dates in months on the R
How do I calculate the difference between two dates in months on the R? Suppose the two dates: x <- as.Date("2014-01-07") y <- as.Date("2015-03-17") I can easily calculate in seconds, minutes,…
-
7
votes2
answers674
viewsRemove an N amount of days on a date
How to remove an amount of N days in a date ? namespace TesteData { class Program { static void Main(string[] args) { var dataAtual = DateTime.Now.Date; // dataAtual 13/09/17 var qtdDias = 5; //Como…
-
7
votes2
answers4291
viewsDifference between date and datetime
I was researching the type of data SQL SERVER and I came across this table What would be the real difference between date and datetime data? Time, minute, second notation only ? What would that…
-
7
votes1
answer8513
viewsHow to do Localdatetime(Datetimezone.forID("America/Sao_paulo")) in Java.time
I wonder if there’s any way to mimic that code on java.time: LocalDateTime(DateTimeZone.forID("America/Sao_Paulo")) I don’t work very well with date in Java, if you can also explain to me what this…
-
7
votes2
answers22159
viewsHow to change time zone (GMT) date and time in JS
I need to update the // data e hora atual a região let data = new Date(); console.log(data); // Está retornando Fri Nov 16 2018 17:04:08 GMT-0200 (Horário brasileiro de verão) var dataBase =…
-
7
votes1
answer1853
viewsWhat does the number returned by System.currentTimeMillis represent?
I went to read the documentation, made available by IDE and came across this: It is said that the method System.currentTimeMillis returns: the Difference, measured in milliseconds, between the…
-
6
votes1
answer1992
viewsHow to schedule an event in Javascript?
Information: I would like to know how to accomplish a Agendamento of an event, that is a function that I would pass as a parameter, that would perform such a dia/mês/ano such hora:minuto that I…
-
6
votes1
answer237
viewsHow to convert a value in UNIX type Timestamp to Datetime?
How to convert a value to type UNIX timestamp (seconds since 1970), example 1396148400, in a DateTime?
-
6
votes2
answers2105
viewstimediff() limited to 838:59:59, how to resolve?
SGBD: MYSQL Problem: I am adding HOURS to a TIME field type and the expected result is above 838:59:59, but is visible only up to this limit. How to solve? SELECT he.empresa,…
-
6
votes2
answers1506
viewsCompare date time with a timespan
On Asp mvc 4, I’m doing a query where I find the data where the hours are lower or equal than those entered by the user. That is, I have a dateTime and check with the user input variable (a…
-
6
votes2
answers895
viewsRemove "/" from a Datetime.Toshortdatestring();
I am implementing a program using C# with . net 3.5 I have the following code: StringBuilder sb = new StringBuilder(); sb.Append(caminhoSalvarCobranca); sb.Append(@"\Boleto ");…