Laravel $q->where() between dates

You can chain your wheres directly, without function(q). There’s also a nice date handling package in laravel, called Carbon. So you could do something like: $projects = Project::where(‘recur_at’, ‘>’, Carbon::now()) ->where(‘recur_at’, ‘<‘, Carbon::now()->addWeek()) ->where(‘status’, ‘<‘, 5) ->where(‘recur_cancelled’, ‘=’, 0) ->get(); Just make sure you require Carbon in composer and you’re using Carbon namespace (use Carbon\Carbon;) … Read more

convert epoch time to date

EDIT: Okay, so you don’t want your local time (which isn’t Australia) to contribute to the result, but instead the Australian time zone. Your existing code should be absolutely fine then, although Sydney is currently UTC+11, not UTC+10.. Short but complete test app: import java.util.*; import java.text.*; public class Test { public static void main(String[] … Read more

Exception when trying to parse a LocalDateTime

It’s a bug: https://bugs.openjdk.java.net/browse/JDK-8031085 The link above also provides the workaround: using a java.time.format.DateTimeFormatterBuilder with a java.time.temporal.ChronoField for the milliseconds field: String text = “20170925142051591”; DateTimeFormatter formatter = new DateTimeFormatterBuilder() // date/time .appendPattern(“yyyyMMddHHmmss”) // milliseconds .appendValue(ChronoField.MILLI_OF_SECOND, 3) // create formatter .toFormatter(); // now it works formatter.parse(text); Unfortunately, there seems to be no way to parse … Read more

Unable to obtain ZonedDateTime from TemporalAccessor using DateTimeFormatter and ZonedDateTime in Java 8

This does not work because your input (and your Formatter) do not have time zone information. A simple way is to parse your date as a LocalDate first (without time or time zone information) then create a ZonedDateTime: public static ZonedDateTime convertirAFecha(String fecha) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(“dd/MM/yyyy”); LocalDate date = LocalDate.parse(fecha, formatter); ZonedDateTime resultado … Read more