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
-
3
votes3
answers1730
viewsChange date format from "yyyy-mm-dd" to "dd/mm/yyyy"
I’m trying to change the shape of a date yyyy-mm-dd for dd/mm/yyyy. I’m using this code: $date = "2019-03-27"; $date1 = new DateTime(date_create_from_format('Y-m-d', $date)->format('d/m/Y'));…
-
3
votes3
answers680
viewsHelp with Sqlquery in context Entity Framework
I need to make a return from my database in a specific way, but I have a problem, the situation is as follows: I have this query already tested directly on SQL Server, and is working perfectly:…
-
3
votes3
answers502
viewsAdd an hour to the current time
I’m trying to record the current system time. For example the current date will be 01-08-2019 10:34:44 and I wanted that same date, but add another hour, IE, would be 01-08-2019 11:34:44.…
-
3
votes3
answers92
viewsLeave date only on the datatime, without the hours part
Hello, I have a project that calls a WebApi which brings the data from the database, but one of the fields in the database is of the type DateTime and in my project, I declared as String (I can…
-
3
votes1
answer294
viewsHow to convert the String "20190930120000[-3:BRT]" to Localdatetime
I got the following String: "20190930120000[-3:BRT]". I need to convert to LocalDateTime. Does anyone know the mask to be used in DateTimeFormatter.ofPattern("?????")? I’ve come this far:…
-
3
votes1
answer1482
viewsTurn String into Localdatetime
I created this Edit Fields button, to change the data of these users I created, the name, name and document are working, without the date of birth is updated, but when I try to edit the Date of…
-
3
votes1
answer946
viewsDate format in python
How to take the current date and format in Brazilian format '28/10/2019'
-
3
votes2
answers256
viewsConvert string to date
I have a date frame whose column that shows me the date has the format 'nov/19' and it’s an Object, I need to convert it to the date format. I know that in the documentation of datetime it is said…
-
3
votes1
answer65
viewsMessage from the validate datetimepicker
Good morning, everyone, I’m having a problem with my form validate() with the datetimepicker in a modal, the message is showing up to the right of the input and before the button, I need it to…
-
3
votes1
answer36
viewsQuery to find duplicate by DATETIME (MYSQL)
Good morning to all. I need help to better understand how to apply a query that I’m developing. I would need to formulate a SELECT to seek certain records within a period involved (DATETIME). On DB:…
-
2
votes2
answers2266
viewsError: "Unexpected T_STRING" in PHP
I took a function from the Internet to calculate the difference between the dates. I created a class to facilitate, because I will use this function on other screens. PHP version: 5.2.* Code calling…
-
2
votes3
answers318
viewsConverting a datetime to text does not show the result
I have a date in this format: Quarta, 21 Maio, 2014. To save this date in the database I’m converting it to datetime as follows: $f['data'] = $_POST['data']; $data = DateTime::createFromFormat('l, j…
-
2
votes1
answer113
viewsFormat Unix Time to display Data only
Good afternoon, am with a problem where I need to remove the time or set the final time always to 23:59:59 if($form) { $start = new \DateTime($form['startDate']); $start = $start->format('U');…
-
2
votes2
answers9275
viewsWrong time problem in PHP (America/Sao_paulo)
I’m running an application in a Centos production environment with updated PHP and Apache. I realized that the logs Cakephp returns a wrong time from the set in php.ini and also set inside the…
-
2
votes2
answers2457
viewsSubtract dates and compare with value
I have two dates: DataAcesso and DataAtual of the kind DateTime. I have one more field called TempoAtualizacaoAutomatica typo byte. I need to subtract these dates and compare the result with…
-
2
votes1
answer570
viewsConversion of string to datetime with specific format
I have a string in the following format: 16Mar2009(mon), but I’m not getting to convert into datetime. string format = "dMMMyyyy(dd)"; DateTime dt = DateTime.ParseExact("16Mar2009(mon)",…
-
2
votes2
answers584
viewsSort by amount of days missing to win
I have this script in my code: $sql = "SELECT * FROM os WHERE status2 <> 'Fechado' ORDER BY XXXXXXX "; $resultado = mysql_query($sql) or die ("Erro na consulta"); while ($linha =…
-
2
votes2
answers1792
viewsGenerate random number with date value and current time with Javascript
I would like to know how to generate a random number, based on the current date and time value, using Javascript. I couldn’t get a real example to show here, because I really don’t know how to do…
-
2
votes1
answer181
viewsHow to set Nothing to a Datetime variable?
I have a function that receives a string and is converted to date time, I did a check for when come string empty, return Nothing. But when I leave the function is returning me the date in this…
-
2
votes1
answer171
viewsReporting
Good night, should be simple thing, but I’m breaking my head and it’s not going. I made a report of the college project "Input Parts in Stock" and is working perfectly. When I did the tests the…
-
2
votes1
answer1608
viewsHow to convert a Decimal value to Datetime?
Can anyone help me with the following question? I have returns of two variables. Examples: 1st - of the type decimal (vdecTotalHoras) and the 2nd - also of the type decimal (vdecMediaAnalise), both…
-
2
votes2
answers3293
viewsDatetimepicker, get first and last day of the month
How do I take the first and last day of the previous month, to fill a DateTimePicker on screen? Ex: Data Inicial 01/07/2015 Data Final 31/07/2015…
-
2
votes1
answer113
viewsError showing past time of multiple PHP posts
<?php function timeAgo($time_ago){ $cur_time = time(); $time_elapsed = $cur_time - $time_ago; $seconds = $time_elapsed ; $minutes = round($time_elapsed / 60 ); $hours = round($time_elapsed /…
-
2
votes1
answer134
viewsDefault value for Datetime column
I have a table that has the field DataRegistro of the kind Datetime. I am using Entityframework to generate the database (I am not using code first) add the property Computed for the column to be…
-
2
votes1
answer321
viewsSend UTC Datetime Javascript to C#
I have an ASP.Net MVC project as follows: In my view I have a Javascript variable that keeps a date: var hoje = new Date(); In my controller have a action which receives via AJAX the value of the…
javascript c# asp.net-mvc datetime serializationasked 9 years, 2 months ago Jedaias Rodrigues 6,718 -
2
votes1
answer3472
viewsString comparison (which answers hours) in javascript is reliable? How does it work?
It is known that, in terms of time, that 07:30 is less than 08:30 - speaking of hours. In javascript, if we make this comparison, everything goes as expected above '07:30' < '08:00' // true…
-
2
votes2
answers675
views -
2
votes1
answer2708
viewsHow to configure ASP.NET MVC validation to accept en-BR dates?
I can’t get the date formatting right in my forms. I tried several cases, all using the same view: @Html.EditorFor(model => model.Data, new { htmlAttributes = new { @class = "form-control" } })…
-
2
votes1
answer3478
viewsConvert string to Datetime
How to take from a string something like "30/01/2015", for example, and convert it to datetime and maintaining the same date format? You can validate the date.
-
2
votes1
answer895
viewsView passing date to Model in wrong format
I’m using Bootstrap-Datapicker as date field in my form and globalizing with moment-with-locales. The configuration I used is as follows:: $('.datetimepicker').datetimepicker({ locale: 'pt-br',…
-
2
votes1
answer2185
viewsSubtract days from current date with PHP
Hello, I would like to know how to decrease, for example like this: $datacurrent = '20/02/2016'; $dataSubtracao = '18/02/2016'; $Calc = $dataAtual - $dataSubtracao; //As a result I wanted to return…
-
2
votes1
answer9153
viewsSQL Convert minutes to minutes:minutes:seconds
How to convert a value in minutes in oracle to the time:minutes:seconds format?
-
2
votes1
answer1049
viewsDate Issue in ASP.NET MVC
In my model I have the following field: [Column("sdt_DataReferencia")] [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")] [Display(Name = "Data Referência")]…
-
2
votes1
answer5886
viewsHow to place the current date and time in a datetime field?
I have a field date in a table that is of the type datetime and I want to put there the current date of my server. I’ve tried everything with NOW() in the insert SQL, but then I saw that it doesn’t…
-
2
votes1
answer67
viewsDelete expiration date information in Wordpress posts
I am using the code below to inform the time it takes for a post to expire on my Wordpress site, whose expiration value I define in a Custom Field (expiration). From this code, as I prevent a post…
-
2
votes1
answer803
viewsStart/End of Summer Time: problem with date verification of type "greater than"
Every year I have two problems, one when the summer schedule starts and the other when it ends. Anyway, yesterday the clock was delayed by an hour that created a giant problem. The page should allow…
-
2
votes1
answer630
viewsHow to restrict the values of a date in a field of a java form?
I have a form built with Swing (Java) that has some fields, among them there is one that is the Date of Birth (a String that receives the value of a date and has a formatted field ##/##/####.) which…
-
2
votes2
answers998
viewsSearch week number of the year through a date in C#
I’m writing a function that gets a string with a date (format dd/mm/aaaa) and it must return a date (in the same format) 4 weeks later. Example: Entrada: 07/04/2016 saída: 05/05/2016 I read about it…
-
2
votes2
answers7804
viewsConvert a dd/MM/yyy string to Datetime
I have a date filter that should receive the information from a textbox and convert it to Datetime, so I can then compare it to another date. The textbox sends the date in the dd/MM/yyyy format, but…
-
2
votes1
answer709
viewsSet time zone for the whole project
I recently hosted an application on a North American server, so the dates are outside the Brazilian time zone. In this way, I would like to know if there is a way to define the time zone once so…
-
2
votes2
answers356
viewsException with timestamp in the database
I want to enter the time and date separately in the database, which have the fields timestamp and data, respectively. And I have the following code to add the fields:…
-
2
votes1
answer580
viewsDatetime attribute error in C# saving to Mysql
I am trying to enter in the Mysql database the date of birth of the user, in C# the attribute data_birth is of type DateTime and in Mysql the attribute data_nascimento is of type Date, to insert C#…
-
2
votes2
answers621
viewsPick up all hours that are between start time and end time with PHP
I’m developing a module and I need to take every hour between 2 hours, initial and final. Example: <?php $hora_inicial = '08:00'; $hora_final = '15:00'; ?> Then you’d have to list 08:00 09:00…
-
2
votes2
answers435
viewsConvert String with AM/PM to Datetime
I have a variable that contains a date with AM/PM: string data = "01/08/2016 9:00 PM"; When I try to convert to DateTime using the method TryParse the result ignores the designator "AM/PM". string…
-
2
votes1
answer332
viewsQuery with variable date in Mysql returning empty
I need to make a query in Mysql setting 3 variables,when only in the case of right integer,more when I include empty return date ta. Follows my query,what could be doing wrong? SET @tipo = 47; SET…
-
2
votes2
answers291
viewsHow to standardize Datetime format for all type fields without using Displayfor or Editorfor in MVC?
In many cases in the application we have to use something like: @Html.Raw(item.data.ToString("dd/MM/yyyy")) can’t be DisplayFor nor EditorFor in no case and we have to show the Brazilian date…
-
2
votes2
answers300
viewsError formatting date:
Hello, I’m formatting the date with the following code: Date data = null; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { data =…
-
2
votes1
answer894
viewsTryparse error of Datetime converting string in Double format
I have a method of using the DateTime.TryParse to convert a string for the guy DateTime, but lately I’ve realized that string format Double would also be being converted to date. Is there any…
-
2
votes3
answers219
viewsoperation with data sqlserver
Gentlemen, I am migrating my Oracle system to SQL Server, I’m having trouble making the following operation SELECT CASE WHEN (EPL.DAT_VENCIMEN - EPL.DAT_FABRICA) > 0 THEN…
-
2
votes2
answers637
viewsTime difference between Javascript and Mysql dates
Have data_inicio and data_fim and I want to know the difference of hours and minutes between them. The data_inicio will already be saved in the Mysql database as datetime, data_fim will pick the…